Search This Blog

15 June, 2011

Simple Java program 4

4. Simple Java programs to know what output will be.


class aaa
{
final private int a=10;  // If object variable is final then the value should be assigned at the declaration time.
public void sam()
{

System.out.println(a);

}
}
class psp
{
public static void main(String aa[])
{
aaa x;
x=new aaa();
x.aaa();

}
}



To execute above program:-
C:\jdk1.6\bin>javac h.java     (h is saved name of this program)
C:\jdk1.6\bin>java psp

O/P:- 10  

-------------------------------------------------------------------------

No comments:

Post a Comment

Meetme@