3. Simple Java programs to know what output will be.
class aaa
{
final private int a;
public void sam()
{
a=10;
System.out.println(a);
}
}
class psp
{
public static void main(String aa[])
{
aaa x;
x=new aaa();
x.aaa();
}
}
O/P:- Compile error because cannot assign a value to final variable a such type in
method because that can be called more times.
-------------------------------------------------------------------------
class aaa
{
final private int a;
public void sam()
{
a=10;
System.out.println(a);
}
}
class psp
{
public static void main(String aa[])
{
aaa x;
x=new aaa();
x.aaa();
}
}
O/P:- Compile error because cannot assign a value to final variable a such type in
method because that can be called more times.
-------------------------------------------------------------------------
No comments:
Post a Comment