Interface

8. Program

//Find the O/P ? Compile Time Error or Compile Successfully

interface L { { } static { } }

9. Program

//Find the O/P ?

interface N { void test1(); } class O implements N { public void test1() { System.out.println("from test "); } public static void main(String[] args) { // N n1 = new N(); O o1 = new O(); N n1 = null; o1.test1(); System.out.println("done"); } }

10. Program

//Find the O/P ?

interface P { void test1(); void test2(int i); } class Q implements P { public void test1() { System.out.println("from test1 "); } public void test2(int j) { System.out.println("from test2 "); } public static void main(String[] args) { Q q1 = new Q(); q1.test1(); q1.test2(10); System.out.println("done"); } }

11. Program

//Find the O/P ?

interface R { void test1(); int test2(); } abstract class S implements R { public void test1() { System.out.println("from test1 "); } } class T extends S { public int test2() { System.out.println("from test2 "); return 20; } public static void main(String[] args) { T t1 = new T(); t1.test1(); System.out.println(t1.test2()); } }

12. Program

//Find the O/P ?

interface U { void test1(); void test2(int i); double test3(boolean b); } abstract class V implements U { public void test2(int i) { System.out.println("from test2 "); } } abstract class W extends V { public void test1() { System.out.println("from test1"); } abstract void test4(); } class X extends W { public double test3(boolean i) { System.out.println("from test3"); return 28.9 ; } void test4() { System.out.println("from test4"); } public static void main(String[] args) { X x1 = new X(); x1.test1(); x1.test2(2); x1.test4(); System.out.println(x1.test3(true)); } }

Page....