//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class W
{
static
{
System.out.println("SIB");
}
W()
{
System.out.println("W()");
}
public static void main(String[] args)
{
W w1 = new W();
System.out.println("------");
W w2 = new W();
System.out.println("------");
}
}
17. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class Y
{
static
{
Y y1 = new Y();
System.out.println("SIB");
}
Y()
{
System.out.println("Y()");
}
public static void main(String[] args)
{
System.out.println("------");
Y y1 = new Y();
System.out.println("------");
}
}
18. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class Z
{
static
{
System.out.println("SIB Begin");
Z z1 = new Z();
System.out.println("SIB End");
}
Z()
{
System.out.println("Z()");
}
public static void main(String[] args)
{
System.out.println("Main Begin");
Z z1 = new Z();
System.out.println("Main End");
}
}
To understand 19 and 20 no. program first understand SUPER KEYWORD
19. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class I
{
I()
{
System.out.println("i()");
}
}
class J extends I
{
J()
{
System.out.println("j()");
}
}
class K
{
public static void main(String[] args)
{
I i1 = new I();
System.out.println("------");
J j2 = new J();
System.out.println("------");
}
}
20. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class L
{
L()
{
System.out.println("L()");
}
}
class M extends L
{
M()
{
System.out.println("M()");
}
}
class N extends M
{
N()
{
System.out.println("N()");
}
}
class O
{
public static void main(String[] args)
{
L l1 = new L();
System.out.println("------");
M m1 = new M();
System.out.println("------");
M n1 = new N();
System.out.println("------");
}
}