JAVA

What is Java?

Java is a set of technologies used in programming language and computing platform for creating and running software. Because Java is often used to refer Java programming language for simplicity.Most importantly it is platform independent this makes a right choice for Web Programming.Similarly a reference about complete java guide is given below.

Java programming language – A powerful, general-purpose, platform-independent, object-oriented programming language.

Features of Java:

  • Architecture-neutral
  • Simple and Portable
  • Object-Oriented
  • Distributed and Secure
  • Compiled
  • Interpreted
  • Statically Typed and well understood language.
  • Secure due to Encapsulation concept it uses keywords like public,private,protected due to this it provides security.
  • Rich set of Library Functions like java.io – for file i/o, exception handling etc.
  • Write code once and run anywhere a unique feature.

Installation of Java:

To run Java Programming in Windows, you’ll need to install two things: JAVA SE Development Kit and IDE to create your Java Projects.For Java SE,Go to the Downloads page of Java Standard Edition Development Kit. For IDE’s use IntelliJ IDEA or Eclipse IDE go to their download page and install.

Java Applications:

  • Stand-alone Application –Just like any programming language
  • Applet–Run under a Java-Enabled Browser. An applet is designed to be embedded in a Web page, and run by a browser.
  • Midlet–Run in a Java-Enabled Mobile Phone.
  • Servlets –Run on a Java-Enabled Web Server.Applets run in a sandbox with numerous restrictions; for example, they can’t read files and then use the network.
  • Applicationan application is a conventional program

What are various Structures of Codes?

  1. To Create a Java Source File:

        public class HelloWorld {
public static void main(String[] args) {
System.out .println(“Hello World!”);
}       }

  • therefore, Compile– javac Hello World.java
  • besides that, One file named Hello World.class is created if the compilation is succeeds.
  • Hence, Run- java Hello World

2. To Create a Java Source File:
HelloWorldApplet.java

import java.applet.Applet;
import java. awt. Graphics;

public class HelloWorldApplet extends Applet {
public void paint(Graphics g) {
g.drawString(“Hello World!”, 5, 25);
}
}

  • therefore, Compile-javac Hello World Applet.java
  • besides that, One file named HelloWorldApplet.class is created if the compilation is succeeds.
  • most importantly applets have a main method…..but it’s in the browser, not in your code.

What is class?

  • Classes are arranged in a hierarchy
  • The root, or topmost, class is Object
  • Every class but Object has at least one superclass.
  • A class may have sub classes. It satisfies all object oriented concepts like Encapsulation,Inheritance,Polymorphism.
  • Each class inherits all the fields and methods of its (possibly numerous) super classes.
  •  An example of class:  Creating and using class.class Person {String name;
    int age;void birthday ( ) {
    age++;
    System.out. println (name + ‘ is now ‘ + age);
    }
    }
  • An example of object: Creating and using object.
  • Person john;
    john = new Person ( );
    john.name = “John Smith”;
    john.age = 37;

Preparation and Execution Of Java Programs:

  • For most languages, compilation produces machine code.
  • Bytecode produced on any platform may be executed on any other platform which supports a Virtual Machine.
  • Java compilation produces “Bytecode”–Intermediate code readable by the Virtual Machine –Transferable across the Internet as applets.