Search This Blog

15 June, 2011

Simple Java program 2

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


class aaa
{
final private int a;
public void sam()
{
System.out.println(a);
}
}
class psp
{
public static void main(String aa[])
{
aaa x;
x=new aaa();
x.aaa();

}
}



O/P:-  Compile error because a is declared as final thus a will not get default value. 
             We have to assign a value to a.
------------------------------------------------------

No comments:

Post a Comment

Meetme@