There are two packages !
1. pack1 ( 3 .java files , file names must be same as class name )
2. pack2 ( 8 .java files , file names must be same as class name)
Program
M.imp Check for each class Compiletion Error / Compiletion Successfully / Output ?
* Package pack1 .java files ?
//1 must save as A.java
package pack1;
public class A
{
public static int i = 10;
public static void test()
{
System.out.println("Done");
}
}
//2 must save as B.java
package pack1;
public interface B
{
int j = 20;
String k = "abc";
}
//3 must save as C.java
package pack1;
public enum C
{
CON1, CON2, CON3
}
* Package Second .java files ?
//1 must save as Manager.java
package pack2;
class Manager
{
public static void main(String[] args)
{
System.out.println(pack1.A.i);
pack1.A.test();
System.out.println(pack1.B.j);
System.out.println(pack1.B.k);
System.out.println(pack1.C.CON1);
System.out.println(pack1.C.CON2);
System.out.println(pack1.C.CON3);
}
}
//2 must save as Manager1.java
package pack2;
import static pack1.A.i; //static import used here
import static pack1.B.j;
class Manager1
{
public static void main(String[] args)
{
System.out.println(i);
System.out.println(j);
}
}
//3 must save as Manager2.java
package pack2;
import static pack1.A.*;
import static pack1.B.*;
import static pack1.C.*;
import static java.lang.System.out;
class Manager2
{
public static void main(String[] args)
{
out.println(i);
test();
System.out.println(i);
System.out.println(j);
}
}
//4 must save as Manager3.java
package pack2;
class Manager3
{
public static void main(String[] args)
{
System.out.println(Integer.MAX_VALUE);
System.out.println(Long.MAX_VALUE);
}
}
//5 must save as Manager5.java
package pack2;
class Manager5
{
public static void main(String[] args)
{
System.out.println("1111");
System.exit(12); // use for terminat exit required int no. in argu.
System.out.println("2222");
}
}
//6 must save as Manager6.java
package pack2;
import static java.lang.System.out;
import static java.lang.System.exit;
class Manager6
{
public static void main(String[] args)
{
System.out.println("1111");
exit(0); //use for terminat exit required any int no. in argu.
System.out.println("2222");
}
}
//7 must save as Manager7.java
package pack2;
import static java.lang.System.*;
class Manager7
{
public static void main(String[] args)
{
out.println("1111");
exit(0);
out.println("2222");
}
}
//8 must save as Manager8.java
package pack2;
import static pack1.A.*;
import pack1.*;
class Manager8
{
public static void main(String[] args)
{
System.out.println(i); // MOst Imp
test();
System.out.println(A.i);
}
}