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.
------------------------------------------------------
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