How to Run JAVA Application

Steps to run the JAVA application:

1. Type the program in the DOS editor or notepad. Save the
file with a .java extension.

2. The file name should be the same as the class, which has the
main method.

3. To compile the program, using javac compiler, type the
following on the command line:
Syntax: javac <>
Example: javac

4. After compilation, run the program using the Java
Syntax: java <filaname> (without the .java
Example: java abc

5. The program output will be displayed on the command line.

Syntax for JAVA

Syntax for a standalone application in Java:

import packages;

class <classname>
         public static void main(String args[])

Variable Keywords in JAVA

Variable Keywords :

The following keywords are a special type of reference variable:

super : Reference variable referring to the immediate super class.
this : Reference variable referring to the current instance of an object.

Primitives in JAVA

Primitives :

The following keywords are primitives:

boolean : A value indicating true or false.
byte : An 8-bit integer (signed).
char : A single Unicode character (16-bit unsigned)
double : A 64-bit floating-point number (signed).
float : A 32-bit floating-point number (signed).
int : A 32-bit integer (signed).
long : A 64-bit integer (signed).
short : A 16-bit integer (signed).

Package in Java

Package Control :

The following are keywords used for package control:

import : Statement to import packages or classes into code.
package : Specifies to which package all classes in a source file belong.

Error Handling in JAVA

Error Handling:

The following are keywords used in error handling:

catch : Declares the block of code used to handle an exception.

finally : Block of code, usually following a try-catch statement, which is
executed no matter what program flow occurs when dealing with an exception.

throw : Used to pass an exception up to the method that called this method.

throws : Indicates the method will pass an exception to the method that
called it.

try : Block of code that will be tried, but which may cause an exception.

assert : Evaluates a conditional expression to verify the programmer’s

Flow Controls In JAVA

Flow Controls :

The following are keywords used to control the flow through a block of code:

break - Exits from the block of code in which it resides.
case - Executes a block of code, dependent on what the switch tests for.
continue - Stops the rest of the code following this statement from
executing in a loop and then begins the next iteration of the loop.
default - Executes this block of code if none of the switch-case
statements match.
do - Executes a block of code one time, then, in conjunction with the
while statement, it performs a test to determine whether the block should
be executed again.
else - Executes an alternate block of code if an if test is false.
for - Used to perform a conditional loop for a block of code.
if - Used to perform a logical test for true or false.
instanceof - Determines whether an object is an instance of a class,
superclass, or interface.
return - Returns from a method without executing any code that follows
the statement (can optionally return a variable).
switch - Indicates the variable to be compared with the case statements.
while - Executes a block of code repeatedly while a certain condition
is true.

Modifiers in JAVA

=>Access Modifiers :

The following are access modifiers:
private : Makes a method or a variable accessible only from within its
own class.
■ protected :Makes a method or a variable accessible only to classes in the
same package or subclasses of the class.
public Makes a class, method, or variable accessible from any other class.

=>Class, Method, and Variable Modifiers :

The following are class, method, and/or variable modifiers:
abstract : Used to declare a class that cannot be instantiated, or
a method that must be implemented by a nonabstract subclass.
class : Keyword used to specify a class.
extends : Used to indicate the superclass that a subclass is extending.
final : Makes it impossible to extend a class, override a method, or
reinitialize a variable.
implements : Used to indicate the interfaces that a class will implement.
interface : Keyword used to specify an interface.
native : Indicates a method is written in a platform-dependent language,
such as C.
new : Used to instantiate an object by invoking the constructor.
static : Makes a method or a variable belong to a class as opposed to
an instance.
strictfp : Used in front of a method or class to indicate that
floating-point numbers will follow FP-strict rules in all expressions.
synchronized : Indicates that a method can be accessed by only one
thread at a time.
transient : Prevents fields from ever being serialized. Transient fields are
always skipped when objects are serialized.
volatile : Indicates a variable may change out of sync because it is used
in threads.

Java Programming Language Keywords

Java Programming Language Keywords :

Identify all Java programming language keywords and correctly constructed identifiers.
Keywords are special reserved words in Java that you cannot use as identifiers (names) for classes, methods, or variables. They have meaning to the compiler; it uses them to figure out what your source code is trying to do. There are following 49 reserved keywords.

Java Programming Language - Reserved Keywords