Wednesday, November 11, 2015

Lession2 :: (Instance variables, Class variables, Local variables)

  • Any variable which is available inside a method is called as local variable.

Example ::

public class Display {
         public void getData(){
                   int a = 10; // Local Variable
         }
}


  • Any variable which is declared inside class and outside of a method is called as instance variable.
  • Any variable which starts with static keyword is called as class variables.

Example ::

public class Display {
       static int x = 10; // Class variable
       int y = 20; // Instance variable

       public void getData(){
             int  z = 30; // Local Variable
       }
}

Lesson 1 :: (About java, javac, javap)

Concepts covering as part of this advanced java are as below ::

1) JDBC
2) JNDI
3) Servlets
4) JSP
5) JSP Custom Tags.

Before I am going to start above concepts i will go through some preliminary things.

  • JAVA is a portable programming language(Platform Independent).

Take one simple java file with name Test as below.

public class Test {
           public static void main(String[] args){
                      System.out.println("Hello Java World");
           }
}

So, as we know to compile a java program we use javac command and to run any java program we use java command.
Example ::

C:/> javac Test.java
C:/> java Test

After executing javac command .class file will be created.

 To open the .class file in command prompt use the following command

  • javap Test 

Test is user defined class name.

Once you compile any java program the compiler translates the java code to java instructions(we can see these instructions in the .class file).

So to see java instructions in the class file we need to use javap command( javap means java profiler)

Syntax ::

javap <class_name>

Example ::

C:\> javap Test

javap is available in java development kit.

  • To see the code which is available in the methods of the class we need to use the following command.
Syntax ::

javap -c <class_name>

Example ::

C:\> javap -c Test