Tuesday 23 June 2015

Important concepts in JAVA

Class:
Class is an entity that represents the state or behaviour of the object.Class may contain data members and member functions.
Syntax:
Class First
{
          public static void main(String[]  args)
          {
                 System.out.println("Fun to learn JAVA");
          }
}
public static void main(String[] args)
public :- The method main() can be accessed by anything including interpreter.
Static :- This keyword tells the compiler that the main() method is used in the class. There is no need of instance to execute the static method.
Void :- it indicates that the main function should not return any value.
String args[] :- the main method is declare with a single parameter “args” which is a type of String array.
COMPILING AND RUNNING THE JAVA PROGRAM
Step1: Type the program in a notepad and save as classname.java and place it in the C:\Program Files\Java\jdk1.7.0_17\bin
Step 2 : open the command prompt change the path to C:\Program Files\Java\jdk1.7.0_17\bin and then to compile type javac classname.java, to run type java classname
Step 3 : output will be displayed.
Instead running the program in command prompt better we can use IDE like netbeans or eclipse.
VARIABLES & SCOPE
There are two ways to describe variables:
à   Variable of primitive type
à   Variable of reference type
We can declare variable inside a method or outside a method.
Variable which is defined inside a method is called local variable. Sometime this is also called as automatic, temporary or stacks variables.
Variable defined outside a method are created when the object is constructed using the new abc() call. Variable can be define outside a method in two ways,
à   Using static keyword is called class variable.
à   Without using static keyword is called as instance variable or member variable.

DEFAULT VALUE OF PRIMITIVE TYPES
VARIABLE
VALUE
Byte
0
Short
0
Int
0L
Long
0.0F
Float
0.0D
Double
‘\u0000’
Boolean
False
All reference types
null

OPERATORS
Important types of operators are there in java programming language.
à   Arithmetic Operator (+, -, *, /)
à   Logical Operator (AND (&), OR (|), NOT (!), XOR (^))
à   Short-circuit logical Operator (&&, ||)

No comments:

Post a Comment