Java Application Programming

Posted on

 

Application Programming

         Application programming also referred as console based programming will be syntactically and semantically similar to ‘C’ (or) ‘C++’ programs. These application programs are executed for the MS-Dos prompt.

Structure of a Java program:

class class_name
{
public static void main(String args[])
{
…………
body of the method;
….….….
}
}

Note:

  • Class: – A reserved keyword with which we create classes.
  • Main: – like in languages such as C and C++, we have the main function where the program execution begins. Similarly in Java the program execution begins at the main method.
  • Method: – method is nothing but the functions in C and C++. In Java we call the functions by the name Methods.

Executing a Java program:

  1. Write a source code and save the code with the name of the class and the extension ” .java”.
  2. Invoke the command prompt and switch to the folder where you saved source code.
  3. Compile the source code using the compiler ” javac”.
    Syntax: – javac filename.java
    Note: If you get back your Dos-prompt, that itself is a conformation that there are no errors in the source code.
  4. When you compile the source code the result is a byte code file with the extension ” .class”. Execute the byte code file using the Interpreter “java”. This is the Java run time system.
    Syntax: – java filename

Output statements in Java:

The output statements in Java is

  1. System.out.print();
  2. System.out.println();