//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class K
{
K()
{
System.out.println("K()");
}
{
System.out.println("IIB-1");
}
K(int i)
{
this();
System.out.println("K(int)");
}
static
{
System.out.println("SIB1");
}
K(int i, int j)
{
this(j);
System.out.println("K(int)");
}
static
{
System.out.println("SIB2");
}
{
System.out.println("IIB-2");
}
public static void main(String[] args)
{
K k1 = new K();
System.out.println("----");
K k2 = new K(20);
System.out.println("-----");
K k3 = new K(100, 200);
System.out.println("-----");
}
}
7. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class I
{
I()
{
System.out.println("I()");
}
{
System.out.println("IIB");
}
I(int i)
{
System.out.println("I(int)");
}
I(double i)
{
this();
System.out.println("I(double)");
}
public static void main(String[] args)
{
I i1 = new I();
System.out.println("------");
I i2 = new I(20);
System.out.println("------");
I i3 = new I(2.2);
}
}
8. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class J
{
J()
{
System.out.println("J()");
}
}
class K extends J
{
K()
{
System.out.println("K()");
super();
}
public static void main(String[] args)
{
System.out.println("done");
}
}
9. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class L
{
L()
{
super();
System.out.println("L()");
this(10);
}
L(int i)
{
super();
System.out.println("L(int)");
}
public static void main(String[] args)
{
System.out.println("done");
}
}
10. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class M
{
M(int i)
{
System.out.println("M(int i)");
}
{
System.out.println("M-IIB");
}
M(int i, int j)
{
System.out.println("M(int i, int j)");
}
}
class N extends M
{
N()
{
super(10, 20);
System.out.println("N(int i, int j)");
}
{
System.out.println("N-IIB");
}
N(int i)
{
this();
System.out.println("N(int i)");
}
N(double i)
{
super(10);
System.out.println("N(double i)");
}
public static void main(String[] args)
{
M m1 = new M(10);
System.out.println("------");
M m2 = new M(10, 20);
System.out.println("------");
N n1 = new N();
System.out.println("------");
N n2 = new N(10);
System.out.println("------");
N n3 = new N(1.0);
}
}