6. Simple Java programs to know what
output will be.
class aaa
{
final private int a;
private int b;
public void sam()
{
System.out.println(a);
}
aaa()
{
a=7;
}
aaa(int e)
{
b=e;
}
}
class psp
{
public static void main(String aa[])
{
aaa x;
x=new aaa();
x.aaa();
}
}
O/P:- Error will generate because x is not assigned in parameterized constructor.
----------------------------------------------------------------------------------------------
output will be.
class aaa
{
final private int a;
private int b;
public void sam()
{
System.out.println(a);
}
aaa()
{
a=7;
}
aaa(int e)
{
b=e;
}
}
class psp
{
public static void main(String aa[])
{
aaa x;
x=new aaa();
x.aaa();
}
}
O/P:- Error will generate because x is not assigned in parameterized constructor.
----------------------------------------------------------------------------------------------
No comments:
Post a Comment