7. 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)
{
x=9;
b=e;
}
}
class psp
{
public static void main(String aa[])
{
aaa x;
x=new aaa();
x.aaa();
}
}
O/P:- 7 // Easily will get compiled because both constructor has value of x.
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)
{
x=9;
b=e;
}
}
class psp
{
public static void main(String aa[])
{
aaa x;
x=new aaa();
x.aaa();
}
}
O/P:- 7 // Easily will get compiled because both constructor has value of x.
No comments:
Post a Comment