//Find the O/P ? Compile Time Error or Compile Successfully ?
class J
{
static int i = test();
static
{
System.out.println("SIB1");
main(null);
System.out.println("SIB End");
}
static int test()
{
System.out.println("test Begin");
main(null);
System.out.println("test End");
return 20;
}
public static void main (String args[])
{
System.out.println("Main :" + i);
}
}
12. Program
//Find the O/P ? Compile Time Error or Compile Successfully ?
class L
{
static
{
System.out.println("SIB-L");
}
public static void main(String args[])
{
System.out.println("L-MAIN");
}
}
class M
{
static
{
System.out.println("SIB-M");
}
public static void main(String args[])
{
System.out.println("M-MAIN-BEGIN");
L.main(args);
System.out.println("M-MAIN-END");
}
}
13. Program
//Find the O/P ? Compile Time Error or Compile Successfully ?
class N
{
static int i = 10;
static
{
System.out.println("SIB-L");
}
}
class O
{
static
{
System.out.println("SIB-O");
}
public static void main(String args[])
{
System.out.println("O-MAIN-BEGIN");
System.out.println(N.i);
System.out.println(N.i);
System.out.println(N.i);
System.out.println("O-MAIN-END");
}
}
14. Program
//Find the O/P ? Compile Time Error or Compile Successfully ?
class P
{
static
{
System.out.println("SIB-L");
}
static void test1()
{
System.out.println("From test1");
}
static int add()
{
return 10;
}
}
class Q
{
static
{
System.out.println("SIB-Q");
}
public static void main(String args[])
{
System.out.println("------");
P.test1();
P.test1();
P.test1();
System.out.println(P.add()); // Void return type method never accepted
System.out.println("------");
}
}