1. Programpackage com.jaladhi;public class Hello { public static void main(String [ ] args) { System.out.println("Hello to All"); } } |
Output :Hello to All |
2. Programpackage com.jaladhi;public class HelloToAll { public static void main(String [ ] args) { System.out.println("Hello to All"); System.out.println("Hello to All"); System.out.println("Hello to All"); System.out.println("Hello to All"); System.out.println("Hello to All"); } } |
Output :Hello to AllHello to All Hello to All Hello to All Hello to All |
3. Programpackage com.jaladhi;public class Literals { public static void main(String [ ] args) { System.out.println("Hello to All"); System.out.println('a'); System.out.println(100); System.out.println(100.9); System.out.println(true); } } |
Output :Hello to Alla 100 100.9 true |
4. Programpackage com.jaladhi;public class Sample { public static void main(String [ ] args) { String s1 = "Hello to all"; char c1 = 'a'; int i = 100; double d1 = 100.2; boolean b1 = true; System.out.println(s1); System.out.println(c1); System.out.println(i); System.out.println(d1); System.out.println(b1); } } |
Output :Hello to alla 100 100.2 true |
5. Programpackage com.jaladhi;public class Methods { public static void main(String [ ] args) { System.out.println("I am in the Main Method"); } public static void test() {} System.out.println("I am in the Test Method"); } } |
Output :I am in the Main Method |
6. Programpackage com.jaladhi;public class FirstMethod { public static void test() { System.out.println("I am in the Test Method"); } public static void main(String [ ] args) { System.out.println("I am in the Main Method"); } public static void testOne() { System.out.println("I am in the Test One Method"); } } |
Output :I am in the Main Method |
7. Programpackage com.jaladhi;public class SecondMethod { public static void main(String [ ] args) { int i = 10; System.out.println(i); i = 20; System.out.println(i); i = 30; System.out.println(i); } } |
Output :1020 30 |
8. Programpackage com.jaladhi;public class ThirdMethod { public static void main(String [ ] args) { System.out.println("Main Method Begins"); testOne(); testOne(); testOne(); System.out.println("Main Method Ends"); } public static void testOne() { System.out.println("TestOne Method"); } } |
Output :Main Method BeginsTestOne Method TestOne Method TestOne Method Main Method Ends |
9. Programpackage com.jaladhi;public class Ondhu { public static void main(String [ ] args) { System.out.println("Main Method"); testOndhu(); testYeradu(); System.out.println("End Method"); } public static void testOndhu() { System.out.println("Test Ondhu Method"); } public static void testYeradu() { System.out.println("Test Yeradu Method"); } } |
Output :Main MethodTest Ondhu Method Test Yeradu Method End Method |
10. Programpackage com.jaladhi;public class Yeradu { public static void main(String [ ] args) { System.out.println("Main Method"); int i = 10; System.out.println(i); } public static test() { System.out.println(i); } } |
Output :Compile Time Error |
11. Programpackage com.jaladhi;public class Mooru { public static void main(String [ ] args) { System.out.println("Main Method"); test(); System.out.println("Main Ends"); } public static void test() { System.out.println("Test Method"); testOndhu(); System.out.println("Test Ends"); } public static void testOndhu() { System.out.println("Test Ondhu Method"); testYeradu(); System.out.println("Test Ondhu Ends"); } public static void testYeradu() { System.out.println("Test Yeradu Method"); int i = 10; System.out.println(i); System.out.println("Test Yeradu Ends"); } } |
Output :Main MethodTest Method Test Ondhu Method Test Yeradu Method 10 Test Yeradu Ends Test Ondhu Ends Test Ends Main Ends |
12. Programpackage com.jaladhi;public class Naalku { public static void main(String [ ] args) { test(1); int i = 10; test(i); test(); } public static void test(int i) { System.out.println(i); } } |
Output :Compile Time Error |
13. Programpackage com.jaladhi;public class Aidhu { public static void main(String [ ] args) { int i = 10; testOndhu(i); System.out.println(i); } public static void testOndhu(int i) { i = 100; } } |
Output :10 |
14. Programpackage com.jaladhi;public class Aru { public static void main(String [ ] args) { int i = 10; System.out.println(i); testOndu(i); System.out.println(i); } public static void testOndu(int m) { m = 10; } } |
Output :1010 |
15. Programpackage com.jaladhi;public class Elu { public static void main(String [ ] args) { int i = 10; i = testOndhu(i); System.out.println(i); } public static int testOndhu(int i) { i = 200; return i; } } |
Output :200 |
16. Programpackage com.jaladhi;public class Entu { public static void main(String [ ] args) { int i = 10; System.out.println(i); i = testOndhu(i); System.out.println(i); public static int testOndhu(int k) { k = 200; return k; } } |
Output :10300 |
17. Programpackage com.jaladhi;public class Ombattu { public static void main(String [ ] args) { testOndhu(); System.out.println(2); } public static void testOndhu() { System.out.println(1); return; } } |
Output :12 |
18. Programpackage com.jaladhi;public class Hattu { public static void main(String [ ] args) { int i; System.out.println(i); } } |
Output :Compile Time Error |
19. Programpackage com.jaladhi;public class Hannondu { public static void main(String [ ] args) { int i = 10; System.out.println(i); } } |
Output :10 |
20. Programpackage com.jaladhi;public class Hanneraḍu { public static void main(String [ ] args) { int i, j; i = j; System.out.println(i); System.out.println(j); } } |
Output :Compile Time Error |
21. Programpackage com.jaladhi;public class Hadimuru { public static void main(String [ ] args) { int i = 10; int j = 10; System.out.println(i); System.out.println(j); } } |
Output :1010 |
22. Programpackage com.jaladhi;public class Hadinalku { public static void main(String [ ] args) { int i; testOndhu(i); System.out.println(i); } public static void testOndhu(int k) { System.out.println(k); } } |
Output :Compile Time Error |
23. Programpackage com.jaladhi;public class Hadinaidu { public static void main(String [ ] args) { int i = 10; testOndhu(i); System.out.println(i); } public static void testOndhu(int k) { System.out.println(k); } } |
Output :1010 |
24. Programpackage com.jaladhi;public class Hadinaaru { public static void testOndhu(int i) { System.out.println(i); int k; k = 0; System.out.println(i); } } |
Output :Run Time Error |
25. Programpackage com.jaladhi;public class Hadineḷu { public static void main(String [ ] args) { int i; System.out.println(i = 10); } } |
Output :10 |
26. Programpackage com.jaladhi;public class Hadinentu { public static void main(String [ ] args) { int i; System.out.println(i = 10); System.out.println(i); } } |
Output :1010 |
27. Programpackage com.jaladhi;public class Hattombattu { public static void main(String [ ] args) { int i; testOndhu(i = 10); System.out.println(i); } public static void testOndhu(int k) { System.out.println(k); } } |
Output :1010 |
28. Programpackage com.jaladhi;public class Ippattu { public static void main(String [ ] args) { System.out.println(i); int i; } } |
Output :Compile Time Error |
29. Programpackage com.jaladhi;public class Ippattondu { public static void main(String [ ] args) { int i = 10; System.out.println(i); } } |
Output :10 |
30. Programpackage com.jaladhi;public class Ippatteradu { public static void main(String [ ] args) { int i = 0; System.out.println(i); int i = 1; System.out.println(i); } } |
Output :Compile Time Error |
31. Programpackage com.jaladhi;public class Ippatmuru { public static void main(String [ ] args) { int i = 0; System.out.println(i); double i = 1; System.out.println(i); } } |
Output :Compile Time Error |
32. Programpackage com.jaladhi;public class Ippatnalku { public static void main(String [ ] args) { int i = 0; System.out.println(i); int j = 1; System.out.println(j); } } |
Output :01 |
33. Programpackage com.jaladhi;public class Ippattaidu { public static void main(String [ ] args) { int i; System.out.println("Hello"); } } |
Output :Hello1 |
34. Programpackage com.jaladhi;public class Ippattelu { public static void main(String [ ] args) { int i = 10; testOndhu(i); } public static void testOndhu(int k) { int k = 20; System.out.println(k); } } |
Output :Compile Time Error |
35. Programpackage com.jaladhi;public class Ippattentu { public static void main(String [ ] args) { int i = 10; testOndhu(i); System.out.println(i); } public static void testOndhu(int k) { int n = 20; System.out.println(k); } } |
Output :1010 |
36. Programpackage com.jaladhi;public class Ippattombattu { public static void main(String [ ] args) { int i = 10; testOndhu(i); System.out.println(i); } public static void testOndhu(int k) { int n = 20; System.out.println(n); } } |
Output :2010 |
37. Programpackage com.jaladhi;public class Muvattu { public static void main(String [ ] args) { testOndhu(2,3); } public static void testOndhu(int i, int i) { System.out.println(i); System.out.println(j); } } |
Output :Compile Time Error |
38. Programpackage com.jaladhi;public class Muvattondu { public static void main(String [ ] args) { testOndhu(2,3); } public static void testOndhu(int i, double i) { System.out.println(i); System.out.println(j); } } |
Output :Compile Time Error |
39. Programpackage com.jaladhi;public class Muvatteradu { public static void main(String [ ] args) { testOndhu(2,3); } public static void testOndhu(int i, int j) { System.out.println(i); System.out.println(j); } } |
Output :23 |
40. Programpackage com.jaladhi;public class Muvatmuru { public static void main(String [ ] args) { testOndhu(10); } public static void testOndhu(int k = 20) { System.out.println(k); } } |
Output :Compile Time Error |
41. Programpackage com.jaladhi;public class Muvatnalku { public static void main(String [ ] args) { testOndhu(11); } public static void testOndhu(int i) { int i = 10; System.out.println(i); } } |
Output :10 |
42. Programpackage com.jaladhi;public class Muvattaidu { public static void main(String [ ] args) { System.out.println("helloworld"); testOndhu(10); System.out.println("Test Ended"); } static void testOndhu(int i) { System.out.println("i"); } } |
Output :helloworldi Test Ended |
43. Programpackage com.jaladhi;public class Muvattaaru { public static void main(String [ ] args) { System.out.println("helloworld"); void test(int i); System.out.println("Test End"); } void test(int i) { System.out.println("i"); } } |
Output :Compile Time Error |
44. Programpackage com.jaladhi;public class Muvattelu { public static void main(String [ ] args) { int i = 09; void i = test(i); System.out.println(i); } void test(int i) { return i; } } |
Output :Compile Time Error |
45. Programpackage com.jaladhi;public class Muvattentu { public static void main(String [ ] args) { System.out.println("helloworld"); test(); System.out.println("Test Ended"); } static void test(int i) { System.out.println(i); } } |
Output :Compile Time Error |
46. Programpackage com.jaladhi;public class Muvattombattu { public static void main(String [ ] args) { int i; i++; System.out.println(i); } } |
Output :Compile Time Error |
47. Programpackage com.jaladhi;public class Nalavattu { public static void main(String [ ] args) { int i=11; i++; System.out.println(i); } } |
Output :12 |
48. Programpackage com.jaladhi;public class Nalavattondu { public static void main(String [ ] args) { System.out.println(i); int i = 10; System.out.println(i); } } |
Output :Compile Time Error |
49. Programpackage com.jaladhi;public class Nalavatteradu { public static void main(String [ ] args) { test(); } static void test() { int j; System.out.println(j); } } |
Output :Compile Time Error |
50. Programpackage com.jaladhi;public class Nalavattmooru { public static void main(String [ ] args) { test(); } static int test() { int j = 15; System.out.println(j); return j; } } |
Output :15 |
51. Programpackage com.jaladhi;public class Nalavattnalku { public static void main(String [ ] args) { int i; test((i = 10)*25); } static void test(int i) { System.out.println(i); } } |
Output :250 |
52. Programpackage com.jaladhi;public class Nalavattaidu { public static void main(String [ ] args) { Nalavattaidu nala = null; System.out.println(nala); } } |
Output :null |
53. Programpackage com.jaladhi;public class Nalavattaaru { public static void main(String [ ] args) { Nalavattaaru nala = null, nala1 = null, naga2; System.out.println(nala2); } } |
Output :Compile Time Error |
54. Programpackage com.jaladhi;public class Nalavattelu { public static void main(String [ ] args) { Nalavattelu nala = null, nala1 = null, naga2; nala2 = nala1 = naga; System.out.println(nala2); } } |
Output :null |
55. Programpackage com.jaladhi;public class Nalavattentu { public static void main(String [ ] args) { boolean flag; if(flag) { System.out.println("true"); } else { System.out.println("false"); } } } |
Output :Compile Time Error |
56. Programpackage com.jaladhi;public class Nalavattombattu { public static void main(String [ ] args) { boolean flag = true; if(flag) { System.out.println("true"); } else { System.out.println("false"); } } } |
Output :true |
57. Programpackage com.jaladhi;public class Aivattu { public static void main(String [ ] args) { int i = 1; int j = 2; int l = 3; int m; System.out.println(i); System.out.println(j); System.out.println(l); System.out.println(m); } } } |
Output :Compile Time Error |
58. Programpackage com.jaladhi;public class Aivattondu { public static void main(String [ ] args) { int i = 1; int j = 2; int l = 3; System.out.println(i); System.out.println(j); System.out.println(l); } } } |
Output :12 3 |
59. Programpackage com.jaladhi;public class Aivatteradu { public static void main(String [ ] args) { boolean flag; if(flag = true) { System.out.println("true"); } else { System.out.println("false"); } } } |
Output :true |
60. Programpackage com.jaladhi;public class Aivattmooru { public static void main(String [ ] args) { boolean flag; if(flag = "true") { System.out.println("true"); } else { System.out.println("false"); } } } |
Output :Compile Time Error |
61. Programpackage com.jaladhi;public class Aivattnalku { public static void main(String [ ] args) { boolean flag; if(flag = false) { System.out.println("true"); } else { System.out.println("false"); } } } |
Output :false |
62. Programpackage com.jaladhi;public class Aivattmooru { public static void main(String [ ] args) { int i = 1; i = i + 10; System.out.println(i); } } |
Output :11 |
63. Programpackage com.jaladhi;public class Aivattnalku { public static void main(String [ ] args) { int i = 10; System.out.println(i++); System.out.println(i); } } |
Output :01 |
64. Programpackage com.jaladhi;public class Aivattnalku { public static void main(String [ ] args) { int i = 10; System.out.println(i--); System.out.println(i); } } |
Output :0-1 |
65. Programpackage com.jaladhi;public class Aivattnalku { public static void main(String [ ] args) { int i = 10; test(i--); } public static void test(int i) { System.out.println(i); } } |
Output :10 |
66. Programpackage com.jaladhi;public class Aivattnalku { public static void main(String [ ] args) { int i = 10; test(i++); test(i); } public static void test(int k) { System.out.println(k); } } |
Output :1011 |
67. Programpackage com.jaladhi;public class Aivattnalku { public static void main(String [ ] args) { int i = 10; int j = i++; System.out.println(i); System.out.println(j); } } |
Output :1110 |
68. Programpackage com.jaladhi;public class Aivattnalku { public static void main(String [ ] args) { int i = 10; int j = i++; int k = i--; System.out.println(i); System.out.println(j); System.out.println(k); } } |
Output :1010 11 |
69. Programpackage com.jaladhi;public class Aivattnalku { public static void main(String [ ] args) { int i = 0; i = i++; System.out.println(i); } } |
Output :0 |
70. Programpackage com.jaladhi;public class Aivattnalku { public static void main(String [ ] args) { int k = 10; k = k--; System.out.println(k); } } |
Output :10 |
71. Programpackage com.jaladhi;public class Aivattnalku { public static void main(String [ ] args) { int i = 0; int j = ++i; System.out.println(i); System.out.println(j); } } |
Output :11 |
72. Programpackage com.jaladhi;public class Aivattnalku { public static void main(String [ ] args) { int i = 0; test(--i); System.out.println(k); } public static void test(int k) { System.out.println(k); } } |
Output :-1 |
73. Programpackage com.jaladhi;public class Aivattnalku { public static void main(String [ ] args) { int i = 10; i = ++i; System.out.println(i); } } |
Output :11 |
74. Programpackage com.jaladhi;public class Aivattnalku { public static void main(String [ ] args) { int i = 10; i = i++ + i++ + i++; System.out.println(i); } } |
Output :3 |
75. Programpackage com.jaladhi;public class Aivattnalku { public static void main(String [ ] args) { int i = 10; i = i++ + i-- + ++i; System.out.println(i); } } |
Output :32 |
76. Programpackage com.jaladhi;public class O { public static void main(String args[]) { int i = 0; i = i++ + tet(i); System.Out.print1n(i); } public static int test(int i){ return i++; } } |
Output :1 |
77. Programpackage com.jaladhi;public class P { public static void main(String args[]) { int i = 0; i = i++ + tet(i++) + i; System.Out.print1n(i); } public static int test(int i){ return i++; } } |
Output :3 |
78. Programpackage com.jaladhi;public class Q { public static void main(String args []) { int i = 0; i = ++i + i-- + test(++i) + ++i; System.out.print(i); } public static int test(int i) { return ++i; } } |
Output :6 |
79. Programpackage com.jaladhi;public class R { public static void main(String args[]) { int i = 0; i = i++ + test1(i++) + test(++i) + test2(i++) + test2(++i); System.out.print1n(i); } public static int test1(int i) { return i++; } public static int test2(int i) { return i++; } } |
Output :14 |
80. Programpackage com.jaladhi;public class Manager1 { public static void main(String args[]) { int i = test(); System.out.print1n(i); } static int test(int i) { return(i*i); } } |
Output :Compile Time Error |
81. Programpackage com.jaladhi;public class Manager1 { public static void main(String args[]) { int i=test(); } static int test() { return 9; } } |
Output :9 |
82. Programpackage com.jaladhi;public class manager1 { public static void main(String args[]} { int i = test(10); Stystem.out.print1n(i); } static int test(int i){ return i*i; } } |
Output :100 |
83. Programpackage com.jaladhi;public class Manager1 { public static void main(String args [] ) { int i = 0; i = i++ + i*10; System.out.print1n(i); } } |
Output :10 |
84. Programpackage com.jaladhi;public class Manager1 { public static void main(String args [] ) { int i = 10; i = i++ + i-- + i*10; System.out.print1n(i); } } |
Output :121 |
85. Programpackage com.jaladhi;public class Manager1 { public static void main(String args[]) { int i = 0; i = i++ + get(i) + ++i + i*10; System.out.print1n(i); } static int get(int i) { return i * 1; } } |
Output :23 |
86. Programpackage com.jaladhi;public class Manager1 { public static void main(String args[]) { int i = 3; i++; System.out.print1n(i); } } |
Output :4 |
87. Programpackage com.jaladhi;public class A { public static void main(String args[]) { System.out.print1n(1); test(); System.out.print1n(20); } public static void test() { System.out.print1n(3); } } |
Output :13 2 |
88. Programpackage com.jaladhi;public class B { public static void test1() { int i = 10; System.out.print1n(i); } public static void main(String args[] ) { int i = 20; System.out.print1n(i); test1(); System.out.print1n(i); test2(); System.out.print1n(i); } public staticvoid test2(){ int i = 30; System.out.print1n(i); } } |
Output :2010 20 30 20 |
89. Programpackage com.jaladhi;public class C { public static int i; public static void main(String args [] ) { System.out.println(i); test(); System.out.println(i); } public static void test() { i = 20; } } |
Output :020 |
90. Programpackage com.jaladhi;public class D { static int j = 10; static void test() { System.out.println(i); } public static void main(String [] args) { System.out.println(i); i = 20; test(); t = 30; test(); } } |
Output :1020 30 |
91. Programpackage com.jaladhi;public class E { static int i = 0; static int j = 10; static void print() { System.out.println(i); System.out.println(j); } public static void main(String [] args) { print(); i = j = 20; print(); i = 30; j = 40; print(); } } |
Output :010 20 30 40 |
92. Programpackage com.jaladhi;public class F { static int i = 10; static int j = i; public static void main(String args[]) { System.out.print1n(i); System.out.print1n(j); } } |
Output :1010 |
93. Programpackage com.jaladhi;public class G { static int i = j; static int j = 10; public static void main(String args[]) { System.out.print1n(i); System.out.print1n(j); } } |
Output :Compile Time Error |
94. Programpackage com.jaladhi;public class H { static int i = test(); static int j = 10; static int test() { return j; } public static void main(String args[]) { System.out.print1n(i); System.out.print1n(j); } } |
Output :010 |
95. Programpackage com.jaladhi;public class I { static int i; static int j = 10; static { i = 100; j = 200; } public static void main (String args []) { System.out.print1n(i); System.out.print1n(j); } } |
Output :100200 |
96. Programpackage com.jaladhi;public class J { static { System.out.print1n("I am in the SIB of J") } public static void main(String args[]) { System.out.print1("I am in the main method"); } } |
Output :I am in the SIB of JI am in the main method |
97. Programpackage com.jaladhi;public class K { public static void main(String args[]) { System.out.print1n("Main method"); } static { System.out.print1n(“SIB method”); } } |
Output :SIB methodMain method |
98. Programpackage com.jaladhi;public class A { static int i; static int j = 10; static { Syatem.out.print1(i); System.out.print1(j); i = 1000; j = 2000; } public static void main(String args[]) { System.out.print1n(i); System.out.print1n(j); } } |
Output :010 100 200 1000 2000 |
99. Programpackage com.jaladhi;public class B { static int i; static { System.out.print1n(i); i = 100; } public static void main(String [] args) { System.out.print1n(i); } static { System.out.print1(i); i = 200; } } |
Output :0100 200 |
100. Programpackage com.jaladhi;public class C { static public int i = 10; } public class D { static int i = 100; public static void main(String [] args) { int i = 1000; System.out.print1n(i); } } |
Output :1000 |
101. Programpackage com.jaladhi;public class E { public static void main(String [] args) { System.out.print1(i); int i = 200; System.out.print1n(i); } } |
Output :1000200 |
102. Programpackage com.jaladhi;public class F { static int i=10; public static void main(String [] args) { System.out.print1n(i); int i = 20; System.out.print1n(i); System.out.println(F.i); } } |
Output :1020 10 |
103. Programpackage com.jaladhi;public class H { static int i; } public class G { public static void main(String [] args) { System.out.print1n(H.i); } } |
Output :0 |
104. Programpackage com.jaladhi;public class I { static int j=10; } public class K { static int j = 20; } public class M { static int j = 30; public static void main(String [] args) { int j = 40; System.out.peint1n(M.j); System.out.print1n(K.j); System.out.print1n(M.j); System.out.print1n(j); } } |
Output :3020 30 40 |
105. Programpackage com.jaladhi;public class R { static void test() { System.out.print1n(“I am in the test of R”); } public class S { static void test() { System.out.priumt1n(“I am in the test of T”); } public static void main(String [] args) { Test(); T.test(); S.test(); R.test(); } } |
Output :I am in the test of TI am in the test of T I am in the test of S I am in the test of R |
106. Programpackage com.jaladhi;public class X { static int i=100; static void test() { System.out.print1n(“I am in the test of X”) } } public class Manager { public static void main(String [] args) { X.test(); } } |
Output :I am in the test of X |
107. Programpackage com.jaladhi;public class Y { static int i = 100; } public class Z { public static void main(String [] args) { System.out.print1(Y.i); } } |
Output :100 |
108. Programpackage com.jaladhi;public class Test1 { static { System.out.print1n("I am in theSIB"); } public class Test2 { static { System.out.print1n(“I am in the class TEST2”); } public static void main(String [] agrs) { System.out.prntl1n("I am in the main TEST2"); } } |
Output :I am in the TEST2I am in the main TEST2 |
109. Programpackage com.jaladhi;public class A { static int i = 10; static { Syatem.out.print1n(“I am in the sib of A”); } } public class B { static void test() { System.out.print1n(“I am in the test of B”); } static { System.out.print1n(“I am in the sib of B”); } } public class manager1 { public static void main(String args [] ) { System.out.print1n(“I am in the main”); System.out.print1n(A.i); B.test(); } } |
Output :I am in the mainI am in the sib of A 10 I am in the sib of B I am in the test of B |
110. Programpackage com.jaladhi;public class A { static { System.out.print1n("I am in the sib of A"); } static void test1() { System.out.print1n("I am in the test1 of A"); } static void test2() { System.out.print1n("I am in the test2 of A"); } } public class B { static int i = 20; static void test() { System.out.print1n("I am in the test of B"); } static { System.out.print1n("I am in the sib of B"); } } public class Manager1 { public static void main (String args []) { System.out.print1n("I am in the main"); A.test1(); A.test2(); B.test(); } } |
Output :I am in the mainI am in the sib of A I am in the test1 of A I am in the test2 of A I am in the sib of B I am in the test of B |
111. Programpackage com.jaladhi;public class A { static { System.out.print1n("I am in the sib of A"); } static void test1() { System.out.print1n("I am in the test1 of A"); } static void test2() { System.out.print1n("I am in the test2 of A"); } } public class B { static int i = 20; static void test() { System.out.print1n("I am in the test of B"); } static { System.out.print1n("I am in the sib of B"); } } public class Manager2 { public static void main (String args []) { System.out.print1n("I am in the main"); System.out.print1n(B.i); B.test(); B.test(); } } |
Output :I am in the mainI am in the sib of B 20 I am in the test of B I am in the test of B |
112. Programpackage com.jaladhi;public class A { static { System.out.print1n("I am in the sib f A"); } static void test1() { System.out.print1n("I am in the tst1 of A"); } static vid test2() { System.out.print1n("I am in the test 2 of A"); } } public class B { static int i = 20; static void test() { System.out.print1n("I am in the test f B"); } static { System.out.priny1n("I am in the sib of B"); } } public class Manager1 { public static void main (String args[]) { System.out.print1n("I am in the maim"); System.out.print1n(B.i); A.test1(); A.test2(); B.test(); } } |
Output :I am in the mainI am in the sib of B 20 I am in the sib of A I am in the test1 of A I am in the test2 of A I am in the test B |
113. Programpackage com.jaladhi;public class ManagerA { static { System.out.print1n(“ I am in the sib of AQ”); } public static void main(String [] args) { System.out.print1n("I am in the main"); } } public class Manager1 { static { System.out.print1n("I am in the sib of B"); } public static void main(String [] args) { System.out.print1n("Manager1 main begin"); ManagerA.main(args); System.out.print1n("Manager1 main end"); } } |
Output :I am in the sib of BManager1 main begin I am in the sib of A I am in the main Manager1 main end |
114. Programpackage com.jaladhi;public class Test { static void method1() { System.out.print1n(“I am in the method of 1 in the test”); } static { System.out.print1n(“I am in the sib oftest”); } public static void main (String[]args) { System.out.print1n(“I am in the main”); } } public class Manager1 { static { System.out.print1n("I am in the sib of B"); } public static void main(String [] args) { System.out.print1n("I manager 1 main begin"); Manager A.main(args); System.out.print1n("manager 1 main end"); } } |
Output :I am in the sib of BI am in the sib of test I am in the method in the test test main begin test main end |
115. Programpackage com.jaladhi;public class Test { static void method1() { System.out.print1n(“I am in the main method 1 in the test)”; } static { System.out.print1n(“I am in the sib of test”); } public static void main(String [] args) { System.out.print1n(“I am in the main”); } } public class Test2 { static { System.out.print1n(“I am in the sib of B”); } public static void main(String [] args) { Test.method1(); System.out.print1n(“test main begin”); System.out.print1n(“test main end”); } } public class Manager1 { public static void main (String args[]); Test2.main(args); System.out.print1n(“I am in the min end”); } } |
Output :I am in the mainbeginI am in the sib of B I am in the sib of test I am in the method 1 in the test test main begin test main end I am in the min end |
116. Programpackage com.jaladhi;public class Manager1 { static { main(null); } public static void main(String [] args) { System.out.print1n("I am in the main"); } } |
Output :I am in the mainI am in the main |
117. Programpackage com.jaladhi;public class Manager1 { static { String all[] = new String[0]; main(all); } public static void main (String args[]) { System.out.print1n("I am in the main"); } } |
Output :I am in the mainI am in the main |
118. Programpackage com.jaladhi;public clsss Manager1 { static { String all[] = new String[0]; main(all); main(null); } public static void main(String args[]) { System.out.println("I am in the main"); } } |
Output :I am in the main |
119. Programpackage com.jaladhi;public class Person { String anme; int age; double weight; double height; double FindRunrate() { double rate = (age/weight)* height; return rate; } } public class Manager1 { public static void main(String args[]) { Person p = new Person(); System.out.print1n(p.name); System.out.print1n(Page); System.out.print1n(p.weight); Systm.out.print1n(p.height); } } |
Output :Null0 0.0 0.0 |
120. Programpackage com.jaladhi;public class Person { String name; int age; double Weaight; double height; double Find Runrate() { double ratre = (age/weight) * height; return rate; } } public class Manager1 { public static void main(String args[]) { Person p = new Person(); p.name = "Ramesh"; p.weight = 59.00; p.height = 5.9; System.out.print1n(p.name); System.out.print1n(p.age); System.out.print1n(p.weight); System.out.print1n(p.height); double rate = p.FindRunrate(); System.out.print1n(rate); } } |
Output :Ramesh29 59.0 5.9 2.9000000000000004 |
121. Programpackage com.jaladhi;public class person { String name; int age; double weight; double heighrt; double Findrunrate() { double rate = (age/weight)*height; } } public class Manager1 { public static vcoid main(String args[]) { Person p = new Person(); Person p1 = new Person(); Person p2 = new Person(); p.name = "Ramesh"; p.age = 29; p.weight = 59.00; p.height = 5.9; p1.name = "Praveen"; p1.age = 25; p1.weight = 63.00; p1.height = 5.8; p2.name = "Kiran"; p2.age = 24; p2.weight = 55.00; p2.height = 5.10; double rate = p.FindRunrate(); System.out.print1n(p.name); System.out.printle(rate); rate = p1.FindRunrate(); System.out.print1n(p1.name); System.out.printle(rate); rate = p2.FindRunrate(); System.out.print1n(p2.name); System.out.print1n(rate); } } |
Output :Ramesh2.9000000000000004 Praveen 2.3015873015873014 Kiran 2.22545454544545 |
122. Programpackage com.jaladhi;pubilc lass Book { String title; String author; double weight; int pages; public String author() { return author; } public int page() { return pages; } } public class Manager1 { public static void main(String args[]) { Book b = newBook(); b.author = "Ramesh"; b.pages = 500; b.title = "Core Java"; b.weight = 2; System.out.print1n(b.author()); System.out.print1n(b.title); System.out.print1n(b.pages); System.out.print1n(b.weight); } } |
Output :RameshCore Java 500 2.0 |
123. Programpackage com.jaladhi;public class Book { String title; String author; double weight; int pages; public double weight() { return weight; } public String title() { return title; } } public class Manager1 { public static void main (String args[]) { Book b = new Book(); b.author = "Ramesh"; b.pages = 500; b.title = "Core Java"; b.weight = 2; System.out.print1n(b.author); System.out.print1n(b.title); System.out.printle(b.page); System.out.print1n(b.weight); System.out.print1n(b.title ()); System.out.print1n(b.weight()); } } |
Output :RameshCore Java 500 2.0 Core Java 2.0 |
124. Programpackage com.jaladhi;public class Person1 { String name; int age; double weight; double height; public void showDays() { System.out.print1n("You are " + age*365 + " days sold"); } } public class Manager1 { public static void main(String args[]) { Person1 p1 = new Person1(); Person1 p2; p1.name = "Ramesh"; p1.age = 29; p1.weight = 59.00; p1 height = 5.9; p2 = p1; p1.showdays(); p2.showdays(); p1 = null; p1.showDays(); } } |
Output :You are 10585 days soldYou are 10585 days sold Null Pointer Exception |
125. Programpackage com.jaladhi;public class A { int i; } public class Manager { public static void main(String args[]) { A a1 = new A(); A a2 = new A(); A a3 = new A(); A a4 = new A(); a1.i = 20; System.out.print1n("a1.i = " + a1.i) } } |
Output :a1.i = 20 |
126. Programpackage com.jaladhi;public class A { int i; } public class Manager { public static void main(String args[]) { A a1 = new A(); A a2 = new A(); A a3 = new A(); A a4 = newA(); a1.i = 20; a2.i = 30; System.out.print1n("a1.i = " + a1.i); System.out.print1n("a2.i = " + a2.i); System.out.print1n("a3.i = " + a3.i); System.out.print1n("a4.i = " + a4.i); } } |
Output :a1.i = 20a2.i = 30 a3.i = 0 a4.i = 0 |
127. Programpackage com.jaladhi;public class C { int i; } public class Manager { public static void main (String args[]) { C c1 = new C(); C c2 = new C(); C c3 = new C(); C c4 = new C(); c1.i = 20; c2.i = 30; System.out.print1n("c3.i = " + c3.i); } } |
Output :c3.i = 0 |
128. Programpackage com.jaladhi;public class B { static int i; } public class Manager { public static void main(String [] args) { B b1 = new B(); B b2 = newB(); B b3 = new B(); B b4 = new B(); b1.i = 22; b2.i = 33; System.out.print1n("b1.i = " + b1.i); Sysyem.out.print1n("b2.i = " + b2.i); System.out.print1n("b3.i = " + b3.i); System.out.print1n("b4.i = " + b4.i); } } |
Output :b1.i = 33b2.i = 33 b3.i = 33 b4.i = 33 |
129. Programpackage com.jaladhi;public class Manager { static int i = 10; static { Manager m1 = new Manager() m1.i = 10; System.out.print1n(m1.i); } public static void main(String args [] ) { Manager m1 = new Manager(); System,out.print1n("m1.i = " + m1.i); } } |
Output :10m1.i = 10 |
130. Programpackage com.jaladhi;public class Manager { int i = 20; static { Manager m1 = new Manager(); m1.i = 10; System.out.print1n(m1.i); } public static void main(String args[]) { Manager m1 = new Manager(); System.out.print1n("m1.i = " + m1.i); } } |
Output :10m1.i = 20 |
131. Programpackage com.jaladhi;public class A { int i; } public class Manager { public static void main(String args[]) { A a1 = new A(); A a2 = new A(); A a3 = new A(); A a4 = new A(); a1.i = 19; System.out.print1n("a1.i = " + a1.i); } } |
Output :a1.i = 19 |
132. Programpackage com.jaladhi;public class A { int i; A() { i++; } A(int k) { i++; } } public class Manager { public static void main(String args[]) { A a1 = new A(); A a2 = newA(); A a3 = newA(); A a4 = new A(); a1.i = 19; System.out.print1n("a1.i = " + a1.i); } } |
Output :a1.i = 19 |
133. Programpackage com.jaladhi;public class A { int i; A() { i++; } A(int k) { i++; } } public class Manager { public static void main(String args[]) { A a1 = new A(); A a2 = new A(); A a3 = newA (); A a4 = newA(); System.out.print1n("a1.i = " + a1.i); } } |
Output :a1.i = 1 |
134. Programpackage com.jaladhi;public class A { static int i; } public class Manager { public static void main(String args[]) { A.i = 19; System.out.print1n(A.i); A a1 = new A(); System.out.print1n(a 1.i); A a2 = new (); System.out.print1n(a2.i): System.out.print1n(“a2.i=”+a2.i); } } |
Output :1919 19 a2.i = 19 |
135. Programpackage com.jaladhi;public class A { public static void test() { System.out.print1n(“I am in the test”); } } public class Manager { public static void main(String args[]) { A a1 = new A(); A a2 = new A(); A a3 = new A(); A a4 = new A(); a1.test(); a2.test(); a3.test(); a4.test(); } } |
Output :I am in the testI am in the test I am in the test |
136. Programpackage com.jaladhi;public class A { int i; static int j; } public class Manager { public static void main(String args[]) { System.out.print1n(A.j); A.j = 10; System.out.print1n(A.j); A a1 = new A(); System.out.print1n(a1.i); a1.i = 10; A a2 = a1; System.out.print1n(a2.i); a2.i = 20; System.out.print1n(a1.i); } } |
Output :010 0 20 |
137. Programpackage com.jaladhi;public class B { int q; static int p; } public class Manager { public static void main(String args[]) { B b1 = newB(); B b2 = newB(); B b3 = null; System.out.print1n(b1.q); System.out.print1n(b2.q = 20); b3 = b2; System.out.println(b3.q); b3.q = 30; System.out.print1n(b2.q); System.out.print1n(b1.q = 100); System.out.print1n(b1.q); System.out.print1n(B.p); } } |
Output :020 20 30 100 100 0 |
138. Programpackage com.jaladhi;public class C { int i; static int j; } public class Manager2 { public static void main(String args[]) { C c1 = null; C c2 = null; C c3 = c1; c2 = new C(); c3 = c1 = c2; c1.i = 100; System.out.print1n(c2.i); System.out.print1n(c3.i); C.j=200; System.out.print1n(C.j); System.out.print1n(c1.i); } } |
Output :100100 200 100 |
139. Programpackage com.jaladhi;public class D { int i; static int k; } public class Manager3 { public static void main(String args[]) { D d1 = new D(); System.out.print1n(d1.i); D1 = null; System.out.print1n(D.k); } } |
Output :Compile Success0 Run Time Error : java.lang.NullPointerExpection |
140. Programpackage com.jaladhi;public class E { int i; } public class Manager4 { public static void main(String srgs[]) { E e1 = null; e1.i = 10; System.out.print1n(“Main Ends”); } } |
Output :Compile Time Successjava.lang.NullpinterException |
141. Programpackage com.jaladhi;public class F { static int i; } public class Manager4 { public static void main ( String args [] ) { F f1 = new F(); f1.i = 100; System.out.print1n(f 1.i); F f2 = new F(); System.out.print1n(f2.i); f2.i = 200; System.out.print1n(f1.i); } } |
Output :100100 200 |
142. Programpackage com.jaladhi;public class G { int i; } public class Managre5 { public static void main(String args[]) { System.out.print1n(G.i); } } |
Output :Compile Time Error (CTE)Non-static variable I cannot be referenced from a static |
143. Programpackage com.jaladhi;public class A { int i; } public class Manager { public static void main(String args[]) { A a1 = new A(); System.out.print1n(a1.i); a1.i = 10; System.out.print1n(a1.i); } } |
Output :010 |
144. Programpackage com.jaladhi;public class B { int i; B() { System.out.print1n(“Cons1”); } B(int i) { System.out.print1n(“Cons2”); } } public class Manager1 { public static void main(String args[]) { B b1 = new B(); System.out.print1n(b1.i); B b2 = newB(10); System.out.print1n(b1.i); System.out.print1n(b2.i); } } |
Output :Cons 10 Cons 2 0 10 10 |
145. Programpackage com.jaladhi;public class C { int i; C() { System.out.print1n(‘Hello to all”); } } public class Manager1 { public static void main(String args[]) { C c1 = new C(); System.out.print1n(c1.i); c1.i = 10; System.out.print1n(c1.i); } } |
Output :Hello to all0 10 |
146. Programpackage com.jaladhi;public class D { int i; D(int i){ System.out.print1n("Cons 1"); } D(){ System.out.print1n("Cons 2"); } } public class Manager2 { public static void main(String args[]) { D d1 = new D(); System.out.print1n(“-------------“); D d2 = new D(); System.out.print1n(“-------------“); D d3 = new D(10); System.out.print1n(“-------------“); D d4 = new D(20): System.out.print1n(“-------------“); new D(); } } |
Output :Cons 2----- Cons 2 ----- Cons 1 ----- Cons 1 ----- Cons 2 |
147. Programpackage com.jaladhi;public class E { int i; E(double i) { System.out.print1n("cons 1"); } E(int i) { System.out.print1n("cons 2"); } E(int i) { System.out.print1n("cons 3"); } } public class Manager3 { public static void main (String args[]) { E e1 = new E(); System.out.print1n(‘----------“); E e2 = new E(10.20); System.out.print1n(“----------“); E e3 = new E(100); } } |
Output :Cons 3----- Cons 1 ----- Cons 2 |
148. Programpackage com.jaladhi;public class F { int i; F() { i = 10; } F(int k) { i = k; } public class Manager5 { public static void main (String args[]) { F f1 = new F(); System.out.print1n(f1.i); F f2 = new F(20); System.out.print1n(f2.i); } } |
Output :1020 |
149. Programpackage com.jaladhi;public class A { int i; static int j; void test() { System.out.print1n(i); } static void test1() { System.out.print1n(j); } } public class Manager { public static void main(String args[]) { A a1 = new A(); System.out.print1n(a1.i); a1.test(); A.test1(); } } |
Output :00 0 |
150. Programpackage com.jaladhi;public class B { int i; static int j; int get() { return i; } void set(int i) { this.i = i; } } public class Manager1 { public static void main(String args[]) { B b1 = new B(); System.out.print1n(b1.i); b1.i=10; int k = b1.get(); System.out.print1n(k); b1.set(20); System.out.print1n(b1.get(); } } |
Output :010 20 |
151. Programpackage com.jaladhi;public class A { int i; static int j; A() { System.out.print1n(i); System.out.print1n(j); } void print() { System.out.print1n(i); System.out.print1n(j); } } public class Manager { public stastic void main(String args[]) { A a1 = new A(); a1.print(); A a2 = new A(); a2.i = 10; a2.j = 20; a2.print(); } } |
Output :00 0 0 0 10 20 |
152. Programpackage com.jaladhi;public class B { int i; static int j; B(int i,int j) { i = i; j = j; } void print() { System.out.print1n(i); System.out.print1n(j); } public static void main(String args []) { B b1 = new B(10,20); b1.print(); } } |
Output :00 |
153. Programpackage com.jaladhi;public class C { int i; static int j; C() { i = 10; j = 20; } C(int k,int m) { i = k; j = m; } void print() { System.out.print1n(i); System.out.print1n(j); } public static void main(String args[]) { C c1 = new C(); C c2 = new C(30,40); c1.print(); c2.print(); } } |
Output :1040 30 40 |
154. Programpackage com.jaladhi;public class D { int i; static int j; public static void main(String args [] ) { D d1 = new D(); d1.i = 10; j = 20; System.out.print1n(d1.i); System.out.print1n(d1.j); D d2 = new D(); d2.i = 100; j = 200; System.out.print1n(d2.i); System.out.print1n(d2.j); } } |
Output :1020 100 200 |
155. Programpackage com.jaladhi;public class B { int i; B(int i) { this.i = i; } } public class Manager1 { public static void main(String [] args) { B b1 = new B(); System.out.println(b1.i); } } |
Output :CTE (Compile Time Error) |
156. Programpackage com.jaladhi;public class A { int i; } public class Manager { public static void main(String args [] ) { A a1 = new A(10); System.out.print1n(a1.i); } } |
Output :Compile Time Error |
157. Programpackage com.jaladhi;public class B { int i; B (int i) { this.i = i; } } public class Manager B1 { public static void main(String args[]) B b1 = new B(); System.out.print1n(b1.i); } } |
Output :Compile Time Error |
158. Programpackage com.jaladhi;public class Manager3 { public static void main(String [] args) { System.out.println(i); } } |
Output :Compile Time Error |
159. Programpublic class Manager3 {static int i; public static void main(String [] args) { System.out.println(i); } } |
Output :Compile Success0 |
160. Programpackage com.jaladhi;public c1ass Manager6 { int i; public static void main( String args [] ) { Manager6 m1 = new Manager6(); System.out.print1n(m1.i); } } |
Output :Compile Success0 |
161. Programpackage com.jaladhi;public class Manager7 { int i; public static void main(String args[]) { Manager6 m1 = new Manager6(10); System.out.print1n(m1.i); } } |
Output :Compile Time Error |
162. Programpackage com.jaladhi;public class D { D() { System.out.print1n(“Hello”); } } public class Manager8 { public static void main(String args[]) { D d1 = new D(); System.out .print1n(“-------------“); D d2 = new D(); System.out.print1n(“--------------“); D d3 = new D(); System.out.print1n(“--------------“); } } |
Output :Hello-------- Hello -------- Hello -------- |
163. Programpackage com.jaladhi;public class E { E() { System.out.print1n(1); } E(int i) { this(); System.out.print1n(2); } } public class Manager10 { public static void main(String args[]) { E e1 = new E(); System.out.print1n(“-----------“); E e2 = new E(10); } } |
Output :1-------- 1 2 |
164. Programpublic class F {F() { this(10); System.out.print1n(1); } F(int i) { System.out .print1n(2); } } public class Manager11 { public static main(String args[]) { F f1 = new F(); System.out.print1n(“---------“); F f2 = new F(20); } } |
Output :21 |
165. Programpackage com.jaladhi;public class G { G() { System.otu.print1n(1); } G(int i, int j) { this(); System.out.print1n(2); } G(int i) { this(i,i); System.out.print1n(3); } } public class Manager12 { public static void main(String args[]) { G g1 = new G(); System.out.print1n(“--------“); G g2 = new G(1); System.out.print1n(“--------“); G g3 = new G(1,2); } } |
Output :1------- 1 2 3 -------- 1 2 |
166. Programpackage com.jaladhi;public class Manager3 { int i; public static void main(String [] args) { Manager3 m = null; System.out.println(m.i); } } |
Output :Compile Success |
167. Programpackage com.jaladhi;public class Manager1 { int i; public static void main(String args[]) { Manager1 m; System.out.print1n(m.i); } } |
Output :CTE (Compile Time Error) |
168. Programpackage com.jaladhi;public class Manager2 { int i; public static void main(String args[]) { Manager2 m; System.out.print1n("Ends"); } } |
Output :Ends |
169. Programpackage com.jaladhi;public class Manager3 { int i; public static void main(String args[]) { Manager3 m = null; System.out.print1n(m.i); } } |
Output :Compile SuccessRun Time Error (java.lang.NullpointerException) |
170. Programpackage com.jaladhi;public class Manager4 { int i; public static void main(String args[]) { Manager4 m = new Manager4(); System.out.print1n(m.i); } } |
Output :0 |
171. Programpackage com.jaladhi;public class Manager5 { int i; Manager5 m; public static void main(String args[]) { System.out.print1n(m.i); } } |
Output :CTE (Compile Time Error) |
172. Programpackage com.jaladhi;public class Manager6 { int i; static Manager6 m; public static void main(String args[]) { System.out.print1n(m.i); } } |
Output :Compile SuccessRun Time Error (java.lang.NullPointerException) |
173. Programpackage com.jaladhi;public class Manager7 { int i; Manager7 m; public static void maian(String args[]) { Manager7 m = null; System.out.print1n(m.m.i); } } |
Output :Compile SuccessRun Time Error (java.lang.NullPointerException) |
174. Programpackage com.jaladhi;public class Manager8 { int i; Manager8 m; public static void main(String args[]) { Manager8 m = null; System.out.print1n(m.m.m.m.i); } } |
Output :Compile SuccessRun Time Error (java.lang.NullPointerException) |
175. Programpackage com.jaladhi;public class A { int i; A a; } public class Manager { public static void main(String args[]) { A a1 = null; System.out.print1n(a1.a.a.a.a.a.a.i); } } |
Output :Compile SuccessRun Time Error (java.lang.NullPointerException) |
176. Programpackage com.jaladhi;public class A { int i; A a; } public class Manager9 { public static void main(String args[]) { A a1 = new A(); test(a 1); } static void test(A a1) { System.out.print1n(a 1.i); } } |
Output :0 |
177. Programpackage com.jaladhi;public class B { int i; void test(B b){ System.out.print1n(b.i); System.out.print1n(i); } } public class Manager10 { public static void main(String args[]) { B b1 = new B(); b1.i = 100; B b2 = new B(); b2.i = 200; b2.test(b1); } } |
Output :100200 |
178. Programpackage com.jaladhi;public class C { int i; void print(C c1, C c2) { System.out.print1n(i); System.out.print1n(this.i); System.out.print1n(c1.i); Syatem.out.print1n(c2.i); } } public class Manager11 { public static void main(String args[]) { C c1 = new C(); C c2 = new C(); C c3 = new C(); c1.i = 10; c2.i = 20; c3.i = 30; c1.print(c2,c3); c1.print(c1,c2); } } |
Output :1020 30 10 10 10 20 |
179. Programpackage com.jaladhi;public class A1 { int i; A1() { System.out.print(1); } } public B extends A1 { B(int i) { System.out.print1n(2); this.i = i; } } public class Manager12 { public static void main (String args[]) { B b1 = new B(20); System.out.print1n(b1.i); } } |
Output :12 20 |
180. Programpackage com.jaladhi;public class A { A(int i) { System.out.print(1); } } public class B extends A { B(int i) { System.out.print1n(2); } } public class Manager { public static void main(String args[]) { A a1 = new A(10); B b1 = new b(20); } } |
Output :CTE (Compile Time Error) |
181. Programpackage com.jaladhi;public class C { C(int i) { System.out.print1n(1); } public class D extends C { D() { System.out.print1n(2); } } public class Manager1 { public static voic main(String agrs[]) { D d1=new D(); } } |
Output :CTE (Compile Time Error) |
182. Programpackage com.jaladhi;public class E { E(double d) { System.out.print1n(1); } } public class F extends E { F() { E(10.0); } } public class Manager2 { public static void main(String args[]) { F f1 = new F(); } } |
Output :CTE (Compile Time Error) |
183. Programpackage com.jaladhi;public class G { G(boolean b) { System.out.print1n(1); } } public classs H extends G { } public class Manager3 { public static void main(String args[]) { Sytem.out.print1n("done"); } } |
Output :CTE (Compile Time Error) |
184. Programpackage com.jaladhi;public classs G1 { G1(boolean b) { System.out.print1n(b); } } public class H1extends G1 { H1() { super(true); System.print1n(1); } } public class Manager3 { public static void main(String args[]) { H1 h1 = new H1(); System.out.print1n(“done”); } } |
Output :True1 Done |
185. Programpackage com.jaladhi;public class I { I(char c1) { System.out.print1n(1); } } public class J extends I { J() { System.out.print1n(2); } J(char c1) { System.out.print1n(3); } } public class Manager4 { public static void main(String args[]) { System.out.print1n("done"); } } |
Output :CTE (Compile Time Error) |
186. Programpackage com.jaladhi;public class K { K() { System.out.print1n(1); } } public class L extends K { L() { System.out.print1n(2); } } public class M extends L { M() { System.out.print1n(3); super(); } } public class Manager5 { public static void main (String args[]) { M m = new M(); } } |
Output :CTE (Compile Time Error)Call to super must be first statement in constructore |
187. Programpackage com.jaladhi;public class N { N() { this(10); System.out.print1n(1); } N(int i) { this(); System.print1n(2); } } public class Manager6 { public static void main(String args[]) { System.out.print1n(“done”); } } |
Output :CTE (Compile Time Error)Recursive constructor invocation |
188. Programpackage com.jaladhi;public class O { O() { System.out.print1n(1); } } public class P extends O { P() { this('a'); System.out.print1n(2); } P(char c1) { this(); System.out.print1n(3); } } public class Manager7 { public static void main(String args[]) { P p1 = new P(); } } |
Output :CTE (Compile Time Error)Recursive constructor invocation |
189. Programpackage com.jaladhi;public class Q { Q() { this(); } } public class Manager8 { Public static void main(String args[]) { Q q1 = new Q(); } } |
Output :CTE (Compile Time Error)Recursive constructor invocation |
190. Programpackage com.jaladhi;public class Q1 { Q1(int i) { this(10); } } public class Manager9 { public static void main (String args[]) { Q1 q1=new Q1(20); } } |
Output :CTE (Compile Time Error)Recursive constructor invocation |
191. Programpackage com.jaladhi;public class Q2 { Q2() { System.out.print1n(1); } } public class Q2 extends Q2 { Q2(int i) { Super(); } } public class Manager10 { public static void main(String args[]) { Q2 q2 = new Q2(20); } } |
Output :CTE (Compile Time Error) |
192. Programpackage com.jaladhi;public class T { T() { System.out.print1n(1); } } public class U extends T { U() { System.out.print1n(2); this(); } } |
Output :Compile Time ErrorCall to this must be first statement in constructor |
193. Programpackage com.jaladhi;public class V { V() { System.out.print1n(1); } void test() { this(); Sysem.out.print1n(2); } } public class Manager11 { public static void main (String args[]) { V v1 = new V(); v1.test(); } } |
Output :Compile Time ErrorCall to this must be first statement in constructor not in method |
194. Programpackage com.jaladhi;public class W { void W() { System.out.print1n(1); } } public class Manager12 { public static void main(String args[]) { W w = new W(); w.W(); } } |
Output :1 |
195. Programpackage com.jaladhi;public class X { X x; X() { this.x = x; } X x(X x) { return x; } } public class Manager13 { public static void main(String args[]) { X x1 = new X(); System.out.print1n("Main Method"); } } |
Output :Main Method |
196. Programpackage com.jaladhi;public class X { X x; X() { System.out.print1n(1); } X x(X x) { return x; } X x() { System.out.print1n(2); return x; } } public class Manager13 { public static void main(String args[]) { X x1 = new X(); System.out.print1n("Main Method"); x1.x(); } } |
Output :1Main Method 2 |
197. Programpackage com.jaladhi;public class X { X x; X(int x) { System.out.print1n(1); System.out.print1n(x); } int x(int x) { return x; } X x() { System.out.print1n(2); return x; } } public class Manager13 { public static void main(String args[]) { X x1 = new X(11); System.out.print1n("Main Method"); x1.x(22); System.out.print1n(x1.x); } } |
Output :111 Main Method Null |
198. Programpackage com.jaladhi;public class A { A() { System.out.print1n("Objected Created"); } A(int i) { System.out.print1n("Objected Created"); } } public class Manager { public static void main(String args[]) { A a1 = new A(); A a2 = new A(10); A a3 = new A(10,20); } } |
Output :Object CreatedObject Created Object Created |
199. Programpackage com.jaladhi;public class A { A() { } A (int i) { } A(int i, int j) { } { System.out.print1n("Objected Created"); } } public class Manager { public static void main(String args[]) { A a1 = new A(); A a2 = new A(10); A a3 = new A(10,20); } } |
Output :Object CreatedObject Created Object Created |
200. Programpackage com.jaladhi;public class A1 { static int p; A1() { p++; } A1(int i) { p++; } A1(int i,int j) { p++; } } public class Manager2 { public static void main(String args[]) { A1 a1 = new A1(); A1 a2 = new A1(10); A1 a3 = new A1(10,20); System.out.print1n(a3.p); } } |
Output :3 |
201. Programpackage com.jaladhi;public class A1 { static int p; A1() { } A1(int i) { } A1(int I,int j) { } { p++; } } public class Manager2 { public static void main(String args[]) { A1 a1 = new A1(); A1 a2 = new A1(10); A1 a3 = new A1(10,20); System.out.print1n(a3.p); } } |
Output :3 |
202. Programpackage com.jaladhi;public class D { int i; D(int i) { System.out.print1n(this.i); this.i = i; } D() { System.out.print1n(); i = 10; } { i = 200; } } public class Manager3 { public astatic void main(String args[]) { D d1 = new D(); System.out.print1n("---------"); D d2 = new D(100); System.out.print1n(d1.i + "." + d2.i); } } |
Output :20010:100 |
203. Programpackage com.jaladhi;public class F { F() { System.out.print1n(1); } F(int i) { this(); System.out.print1n(2); } { System.out.print1n(3); } } public class Manager4 { public static void main(String args[]) { F f1 = new F(); System,.out.print1n(“-------“); F f2 = new F(10); } } } |
Output :31 ----- 3 1 2 |
204. Programpackage com.jaladhi;public class H { int i,j,k; H(int i) { i++; } H(int i,int j) { i++; j++; } H(int i,int j,int k) { i++; j++; k++; } } pubic class Manager5 { public static void main(String args[]) { H h1 = new H(1); H h2 = new H(1,2); H h3 = new H(1,2,3); System.out.print1n(h1.i); System.out.print1n(h2.i+ "." + h2.j); System.out.print1n(h3.i+ "." + h3.j + "." + h3.k); } } |
Output :0:00:0:0 |
205. Programpackage com.jaladhi;public class H { int i,j,k; H(int i){ this.i = i++; } H(int i,int j) { this.i = i++; this.j = j++; } H(int i,int j,int k) { this.i = i++; this.j = j++; this.k = k++; } } public class Manager5 { public static void main(String args [] ) { H h1 = new H(1); H h2 = new H(1,2); H h3 = new H(1,2,3); System.out.print1n(h1.i); System.out.print1n(h2.i + "." + h2.j); System.out.print1n(h3.i + "." + h3.j + "." + h3.k); } } |
Output :11:2 1:2:3 |
206. Programpackage com.jaladhi;public calass Manager2 { private Manager2() { System.out.print1n("hello"); } private void Manager() { System.out.printl1n("hai"); } public static void main(String [] args) { new Manager2(); } } |
Output :hello |
207. Programpackage com.jaladhi;public class Manager2 { private Manager2() { System.out.println("Private Constructor"); return; } private void Manager() { System.out.printl1n("hai"); } public static void main(String [] args) { new Manager2(); } } |
Output :Private Constructor |
208. Programpackage com.jaladhi;public class Manager2 { private Manager2(int i) { System.out.print1n("I"); } Manager2(int j) { System.out.print1n("J"); } public static void main(String [] args) { new Manager2(1); } } |
Output :CTE (Compile Time Error)Manager2(int) is already defind in Manager2 |
209. Programpackage com.jaladhi;public class Manager2 { Manager2 mgr = new Mnager2(); Manager2() { Syatem.out.print1n (1); } public static void main(String args [] ) { new Manager2(); } } |
Output :CTE (Compile Time Error) |
210. Programpackage com.jaladhi;public class T { static { System.out.print1n(1); } { System.out.print1n(2); T() { System.out.print1n(3); } } public class Manager extends T { Manager() { System.out.print1n(4); } static { System.out.print1n(5); } { System.out.print1n(6); } public static void main(String args [] ) { new Manager(); } } |
Output :15 2 3 6 4 |
211. Programpackage com.jaladhi;public class Manager { Manager(Manager m) { super(); System.out.print1n(1); } public static void main(String args[]) { new Manager(new Object()); } } |
Output :Compile Time ErrorConstructor Manager(java.lang.Object) |
212. Programpackage com.jaladhi;public Class A { public void test() { System.out.print1n("Test Method"); } } public class Manager { public static void main(String args [] ) { A a1 = new A(); A1.test(); } } |
Output :Test Method |
213. Programpackage com.jaladhi;public class A { int i,j; abstract void test(); } public class Manager { public static void main(String args [] ) { } } |
Output :Compile Time ErrorAbstract Method rest in type A can only be defined by an abstract class |
214. Programpackage com.jaladhi;abstract class A { int i,j; abstract void test(); } public class Manager { public static void main(String [] args) { } } |
Output :Compile Success |
215. Programpackage com.jaladhi;abstract class B { absrtract void test() { } } |
Output :Compile Time ErrorAbstract mathods cannot have a body |
216. Programpackage com.jaladhi;public class C { void test() { } } |
Output :Compile Success |
217. Programpackage com.jaladhi;abstract class D { abstract void test(); } |
Output :Compile Success |
218. Programpackage com.jaladhi;abstract class E { void test() { } } |
Output :Compile Success |
219. Programpackage com.jaladhi;abstract class A { } public class Manager extends A { public static void main(String [] args) { } } |
Output :Compile Success |
220. Programpackage com.jaladhi;abstract class F { abstract void test1(); void test2() { } abstract void test3(); } |
Output :Compile Success |
221. Programpackage com.jaladhi;public class A { } abstract class Manager extends A { public static void main(String [] args) { } } |
Output :Compile Success |
222. Programpackage com.jaladhi;abstract class G { void test() { } abstract void test(int i); void test(double d) { } abstract void eest(char c); } |
Output :Compile Success |
223. Programpackage com.jaladhi;abstract class H { void test() { } abstract void test(); } |
Output :CTE (Compile Time Error) |
224. Programpackage com.jaladhi;abstract class A { abstract void test1(); } abstract class B extends A { void test1() { } } public class Manager { public static void main(String [] args) { } } |
Output :Compile Success |
225. Programpackage com.jaladhi;abstract class A { abstract void test1(); } abstract class B extends A { } public class C extends B { void test1(){ System.out.print1n(“hello”); } } public class Manager { public static void main(String [] args) { } } |
Output :Compile Success |
226. Programpackage com.jaladhi;abstract class A { abstract void test1(); } public class B extends A { void test1() { System.out.print1n(“test()defined”); } public class Manager { public static void main(String [] args) { B b1 = new B(); b1.test1(); } } |
Output :test() defined |
227. Programpackage com.jaladhi;abstract class A { abstract void test1(); } class B extends A { void test1() { System.out.print1n("test() defined"); } } public class Manager { public static void main(String [] args) { B b1 = new B(); b1.test2(); } } |
Output :CTEThe method test2()is undefined for the type B |
228. Programpackage com.jaladhi;abstract class A { abstract void test2(); } public class B extends A { void test1() { System.out.print1n("test() defined"); } } public class Manager { public static void main(String [] args) { B b1 = new B(); b1.test2(); } } |
Output :CTEThe type B must implement abstract method A.test2() |
229. Programpackage com.jaladhi;abstract class A { abstract void test2(); } public class B extends A { void test2() { System.out.print1n("test() defined"); } } public class Manager { public static void main(String [] args) { A a1 = new A(); a1.test2(); } } |
Output :CTECannot instantiate the type A. We cannot creat object to abstract class. |
230. Programpackage com.jaladhi;abstract class Manager { int i; abstract void test2(); static void disp() { System.out.print1n("Inside static method of abstract class"); } public static void main(String [] args) { Manager.disp(); } } |
Output :Inside static method of abstract class |
231. Programpackage com.jaladhi;abstract class Manager { int i; abstract vid test2(); static void disp() { System.out.print1n("Inside static method of abstract class"); } public static void main(String [] args) { } } |
Output :Compile Success |
232. Programpackage com.jaladhi;abstract class A { int i; abstract void test2(); abstract void disp(); } public class Manager extends A { void test() { System.out.print1n(“test() defined”); } void dip() { System.out.print1n(“Inside static method of abstract class”); } public static void main(String [] args) { Manager b1 = new Manager(); b1.test2(); } } |
Output :Compile Error |
232. Programpackage com.jaladhi;abstract class A { int i; abstract void test2(); abstract disp(); } public class Manager extends A { void test2() { System.out.print1n(“test() defined”); } void disp() { System.out.print1n("Inside static method of abstract class"); } public static void main(String [] args) { Manager b1 = new Manager(); b1.test1(); } } |
Output :CTEThe method test1() is undefined for the type Manager |
233. Programpackage com.jaladhi;public class I { void test() { } int test(int a) { return 100; } } |
Output :Compile Success |
234. Programpackage com.jaladhi;public class J { void test() { } int test() { return 100; } } |
Output :Compile Time Error |
235. Programpackage com.jaladhi;public class L { private void test() { } int test() { return 100; } } |
Output :Compile Time Error |
236. Programpackage com.jaladhi;public class L { private void test() { } int test1() { return 100; } } |
Output :Compile Success |
237. Programpackage com.jaladhi;abstract class A { void test() { } abstract void test(int i); } public class B extends A { void test(int i) { } } public class C extends B { void test(int i) { } } |
Output :Compile Success |
238. Programpackage com.jaladhi;abstract class X { abstract void test(); } public class Y extends X { void test() { System.out.print1n("test"); } } public class Manager { public static void main(String [] args) { Y y1 = new Y(); Y1.test(); } } |
Output :Test |
239. Programpackage com.jaladhi;abstract class R { } abstract c;lass S extends R { } public class Z extends S { } |
Output :Compile Time Error |
240. Programpackage com.jaladhi;public class R { } public class S extends R { } public class T extends S { } public class Manager { public static void main(String [] args) { } } |
Output :Compile Success |
241. Programpackage com.jaladhi;abstract class G { abstract static void test() { System.out.print1n(“A”); } } public class Manager1 { public static void main(String [] args) { System.out.print1n(“Manager”); } } |
Output :Compile Time Error |
242. Programpackage com.jaladhi;abstract class G { static void test() { System.out.print1n(“A”); } } public class Manager1 { public static void main(String [] args) { System.out.print1n(“Manager”); } } |
Output :Manager |
243. Programpackage com.jaladhi;abstract class G { static void test() { System.out.print1n(“G”); } } public class Manager1 { public static void main(String [] args) { System.out.print1n(G.test()); } } |
Output :CTE (Compile Time Error) |
244. Programpackage com.jaladhi;abstract class G { static void test() { Ststem.out.print1n(“G”); } } public class Manager1 { public static void main(String [] args) { G.test(); } } |
Output :G |
245. Programpackage com.jaladhi;abstract class G { abstract void test(); } public class Manager1 { public static void main(String [] args) { System.out.print1n(“Manager”); } } |
Output :Manager |
246. Programpackage com.jaladhi;public abstract class Manager1 { public static void main(String [] args) { System.out.print1n(“Manager”); } } |
Output :Manager |
247. Programpackage com.jaladhi;abstract class G { void test() { System.out.print1n(“A”); } } public class Manager1 extends G { void test() { System.out.print1n(“Manager”); } public static void main(String [] args) { G a1 = new Manager1(); a1.test(); } } |
Output :Manager |
248. Programpackage com.jaladhi;abstract class G { void test() { System.out.print1n(“A”); } } public class Manager1 extends G { void test() { System.out.print1n(“Manager”); } public static void main(Strung [] args) { G a1 = new Manager11(); (G)q1.test(); } } |
Output :Manager |
249. Programpackage com.jaladhi;final abstract class G { void test() { System.out.print1n(“A”); } } public classr1 extends G { void test() { System.out.print1n(“Manager”); } public static void main(String [] args) { Manager1 a1 = new Manager1(); a1.test(); } } |
Output :CTEThe class G can have either abstract or final not both |
250. Programpackage com.jaladhi;final class G { void test() { System.out.print1n(“A”); } } abstract class Manager1 extends G { void test() { Ststem.out.print1n(“Manager”); } public static void main(String [] args) { } } |
Output :CTEManager1 cannot be sub class to final class G. |
251. Programpackage com.jaladhi;abstract interface G { void test(); } public class Manager1 extends G { void test() { System.out.print1n(“Manager”); } public static void main(String [] args) { Manager1 a1=new Manager1(); a1.test(); } } |
Output :CTE |
252. Programpackage com.jaladhi;abstract class G { void test() { } } final class Manager extends G { void test() { System.out.print1n(“Manager”); } public static void main(String [] args) { Manager1 a1 = new Manager1(); } } |
Output :Compile SuccessManager |
253. Programpackage com.jaladhi;public class A { void test() { System.out.print1n(“Test Method”); } } public class Manager { public static void main(String args [] ) { A a1 = new A(); a1.test(); } } |
Output :Test Method |
254. Programpackage com.jaladhi;public class A { void test() { System.out.print1n(“Test Method”); } } public class Manager { public static void main(String args [] ) { A a1 = new A(); a1.test(); } } |
Output :Test Method |
255. Programpackage com.jaladhi;public class A { int i,j; abstract void test(); } public class Manager { public static void main(String [] args) { } } |
Output :CTEAbstract Method test in type A can only be defined by an abstract class |
256. Programpackage com.jaladhi;abstract class A { int j; abstract void test(); } public class Manager { public static void main(String [] args) { } } |
Output :Compile Success |
257. Programpackage com.jaladhi;abstract class B { abstract void test() { } } |
Output :Compile Time ErrorAbstract Methods cannot have a body |
258. Programpackage com.jaladhi;public class C { void test() { } } |
Output :Compile Success |
259. Programpackage com.jaladhi;abstract class D { abstract coid test(); } |
Output :Compile Success |
260. Programpackage com.jaladhi;abstract class E { void test() { } } |
Output :Compile Success |
261. Programpackage com.jaladhi;abstract class A { } public class Manager extends A { public static void main(String [] args) { } } |
Output :Compile Success |
262. Programpackage com.jaladhi;abstract class F { abstract void test1(); void test2() { } abstract void test3 (); } |
Output :Compile Success |
263. Programpackage com.jaladhi;public class A { } abstract class Manager extends A { public static void main(String [] args) { } } |
Output :Compile Success |
264. Programpackage com.jaladhi;abstract class G { void test() { } abstract void test(int i); void test(double d) { } abstract void test(char c); } |
Output :Compile Success |
265. Programpackage com.jaladhi;abstract class H { void test() { } abstract void test(); } |
Output :Compile Time Error (CTE) |
266. Programpackage com.jaladhi;abstract class A { abstract void test1(); } abstract class B extends A { void test1() { } } public class Manager { public static main(String [] args) { } } |
Output :Compile Success |
267. Programpackage com.jaladhi;abstract class A { abstract void test1(); } public abstract class B extends A { } public class C extends B { void test1() { System.out.print1n(“hello”); } } public class Manager { public static void main(String [] args) { } } |
Output :Compile Success |
268. Programpackage com.jaladhi;abstract class A { abstract void test1(); } public class B extends A { void test1() { System.out.print1n(“test()defined”); } } public class Manager { public static void main(String [] args) { B b1 = new B(); b1.test 1(); } } |
Output :test() defined |
269. Programpackage com.jaladhi;abstract class A { abstract void test1(); } public class B extends A { void test1() { System.our.print1n("test() defined"); } } public class Manager { public static void main(String [] args) { B b1 = new B(); b1.test2(): } } |
Output :CTEThe method test2() is undefined for the type B |
270. Programpackage com.jaladhi;abstract class A { abstract void test2(); } public class B extends A { void test1() { System.out.print1n("test() defind"); } } public class Manager { public static void main(String [] args) { B b1 = new B(); b1.test2(); } } |
Output :CTEThe type B must implement the inherited abstract method A.test2() |
271. Programpackage com.jaladhi;abstract class { void test2() { System.out.print1n("test() defined"); } } public class Manager { public static void main(String [] args) { A a1 = new A(); a1.test2(); } } |
Output :CTECannot instantiate the type A. We cannot create object to abstract class. |
272. Programpackage com.jaladhi;abstract class Manager { int i; abstract void test2(); static void disp() { System.out.print1n("Inside static method of abstract class"); } public static void main(String [] args) { Manager.disp(); } } |
Output :Inside static method of abstract class |
273. Programpackage com.jaladhi;abstract class Manager { int i; abstract void test2(); static void disp() { System.out.print1n("Inside static method of abstract class"); } public static void main (String [] args) { } } |
Output :Compile Success |
274. Programpackage com.jaladhi;abstract class A { int i; abstract void test2(); abstract void disp(); } public class Manager extends A { void test() { System.out.print1n("test() defined"); } void disp() { System.out.print1n("Inside static method of abstract class"); } public static void main(String [] args) { Manager b1 = new Manager(); b1.test2(); } } |
Output :Compile Time Error |
275. Programpackage com.jaladhi;abstract class A { int i; abstract void test2(); abstract disp(); } public class Manager extends A { void test2() { System.out.print1n("test() defined"); } void didp() { System.out.print1n("Inside static method of abstract class"); } public static void main(String [] args) { Manager b1 = new Manager(); b1.test1(); } } |
Output :CTEThe method test1() is undefined for the type Manager |
276. Programpackage com.jaladhi;public class I { void test() { } int test(int a) { return 100; } } |
Output :Compile Success |
277. Programpackage com.jaladhi;public class J { void test() { } int test(int a) { return 100; } } |
Output :Compile Time Error. test() already defined in J |
278. Programpackage com.jaladhi;public class L { private void test() { } int test() { return 100; } } |
Output :Compile Time Error. |
279. Programpackage com.jaladhi;public class L { private void test() { } int test1() { return 100; } } |
Output :Compile Success |
280. Programpackage com.jaladhi;abstract class A { void test() { } abstract void test(int i); } public class C extends B { void test(int i) { } } |
Output :Compile Success |
281. Programpackage com.jaladhi;abstract class X { abstract void test(); } public class Y extends X { void test() { System.out.print1n("test"); } } public class Manager { public static void main(String args [] ) { Y y1 = new Y(); y1.test(); } } |
Output :test |
281. Programpackage com.jaladhi;abstract class R { } abstract S extends R { } public class Z extends String { } |
Output :CTE(Compile Time Error) |
282. Programpackage com.jaladhi;public class R { } public class S extends R { } public class T extends S { } public class Manager { public static void main(String [] args) { } } |
Output :Compile Success |
283. Programpackage com.jaladhi;abstract class G { static void test() { System.out.print1n("A") } } public class Manager1 { public static void main(String [] args) { System.out.print1n("G.test()"); } } |
Output :CTE(Compile Time Error) |
284. Programpackage com.jaladhi;abstract class G { static void test() { System.out.print1n("G"); } } public class Manager1 { public static void main(String [] args) { G.test(); } } |
Output :G |
285. Programpackage com.jaladhi;abstract class G { abstract void test(); } public class Manager { public static void main(String [] args) { System.out.print1n("Manager"); } } |
Output :Manager |
286. Programpackage com.jaladhi;public abstract class Manager { public static void main(String [] args) { System.out.print1n("Manager"); } } |
Output :Manager |
287. Programpackage com.jaladhi;abstract class G { void test() { System.out.print1n("A"); } } public class Manager1 extends G { void test() { System.out.print1n("Manager"); } public static void main(String [] args) { G a1 = new Manager1(); a1.test(); } } |
Output :Manager |
288. Programpackage com.jaladhi;abstract class G { void test() { System.out.print1n("A"); } } public class Manger1 extends G { void test() { System.out.print1n("Manager"); } public static void masin(String [] args) { G a1 = new Manager1(); ((Ga1).test1(); } } |
Output :Manager |
289. Programpackage com.jaladhi;final abstract class G { void test() { System.out.print1n("A"); } } public class Manager1 extends G { void test() { System.out.print1n("Manager"); } public static void main(String [] args) { Manager1 a1 = new Manager1(); a1.test(); } } |
Output :CTE (Compile Time Error)The class G can have either abstract or final not both |
290. Programpackage com.jaladhi;final class G { void test() { System.out.print1n("A"); } } absrtract class Manager1 extends G { void test() { System.out.print1n("Manager"); } public static void main(String [] args) { } } |
Output :CTE (Compile Time Error)Manager1 cannot be sub class to final class G. |
291. Programpackage com.jaladhi;abstract interface G { void test(); } public class Manager1 extends G { void test() { System.out.prunt1n("Manager"); } public static void main(String [] args) { Manager1 a1 = new Manager1(); a1.test(); } } |
Output :CTE (Compile Time Error) |
292. Programpackage com.jaladhi;abstract class G { void test() { System.out.print1n("A"); } } public class Manager1 extends G { void test() { System.out.print1n("Manager"); } public static void main(String [] args) { Manager1 a1=new Mqanager1(); a1.test(); } } |
Output :Compile Success |
293. Programpackage com.jaladhi;interface A { void test1(); } interface B extends A { void test2(); } public class C impilements B { public void test1() { System.out.print1n("test1"); } public void test2() { System.out.print1n("test2"); } } public class Manager { public static void main(String args [] ) { C c1 = new C(); c1.test1(); c1.test2(); } } |
Output :test1test2 |
294. Programpackage com.jaladhi;interface A { void test1(); } interface B { void test1(int i); } interface C extends A, B { void test1(double d); } public class D implements A, B, C { public void test() { System.out.print1n("test"); } public void test1(int K) { System.out.print1n("int"); } public void test12(double d) { System.out.print1n("double"); } } public class Manager { public static void main(String args [] ) { D d1 = new D(); d1.test1(); d1.test1(10); d1.test1(100,20); } } |
Output :testint double |
295. Programpackage com.jaladhi;interface A { void test1(); } abstract class B { public abstract void test1(); } public class C extends B implements A { public void test1() { System.out.print1n("test"); } } public class Manager { public static void main(String args [] ) { C c1 = new C(); c1.test1(); } } |
Output :test |
296. Programpackage com.jaladhi;public class E { public void test1() { System.out.print1n("super-E"); } } interface B { void test1(); } public class C extends E implements B { } public class Manager { public static void main(String args [] ) { C c1 = new C(); c1.test1(); } } |
Output :super-E |
297. Programpackage com.jaladhi;interface A { void test1(); } public class B { public void test1() { System.out.print1n("test of B"); } } public class C extends B { } public class D exends C { } public class E extends D { } public class Manager { public static void main(String args [] ) { E e1 = new E(); e1.test1(); } } |
Output :test of B |
298. Programpackage com.jaladhi;public class A { public void test1() { System.out.print1n("test1-A"); } } public class B extends A { public void test2() { System.out.print1n("test2-B"); } } interface C { void test1(); void test2(); } public class D extends B implements C { } public class Manager { public static void main(String args [] ) { D d1 = new D(); d1.test1(); d1.test2(); } } |
Output :test1-Atest2-B |
299. Programpackage com.jaladhi;interface A { public void test1(); } interface B extends A { void test2(); } public class C implements B { public void test1() { System.out.print1n("test1"); } public void test2() { System.out.print1n("test2"); } } public class Manager { public static void main(String args [] ) { C c1 = new C(); c1.te3st1(); c1.test2(); } } |
Output :test1test2 |
300. Programpackage com.jaladhi;interface A { void test1(); } interface B { void test1(int i); } interface C extends A,B { void test1(double d); } public class D implements A,B,C { public void test1() { System.out.print1n("test"); } public void test1(int k) { System.out.print1n("int"); } public void test1(double d) { System.out.print1n("double"); } } public class Manager { public static void main(String args [] ) { D d1 = new D(); d1.test1(); d1.test1(10); d1.test1(100.20); } } |
Output :testint double |
301. Programpackage com.jaladhi;interface A { void test1(); } public abstract class B { public abstract void test1(); } public class C extends B implements A { public void test1() { System.out.print1n("test"); } } public class Manager{ public static void main(String args [] ) { C c1 = new C(); c1.test1(); } } |
Output :Test |
302. Programpackage com.jaladhi;public class E { public void test1() { System.out.println("Super - E"); } } interface B { void test1(); } public class C extends E implements B { } public class Manager { public static void main(String args [] ) { C c1 = new C(); c1.test1(); } } |
Output :super-E |
303. Programpackage com.jaladhi;interface A { void test1(); } public class B { public void test1() { System.out.print1n("test of B"); } } public class C extends B { } public class D extends C { } public class E extends D { } public class Manager { public static void main(String args [] ) { E e1 = new E(); e1.tst1(); } } |
Output :test of B |
304. Programpackage com.jaladhi;public class A { public void test1() { System.out.print1n("test1-A"); } } public class B extends A { public void test2() { System.out.print1n("test2-B"); } } interface C { void test1(); void test2(); } public D extends B impilements C { } public class Manager { public static void main(String args[]) { D d1 = new D(); d1.test1(); d1.test2(); } } |
Output :test1-Atest2-B |
305. Programpackage com.jaladhi; | |
395. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public class Manager { public static void main(String [] args) { B b1 = new C(); A a1 = b1; C c1 = (C)a1; System.out.println(c1.k); } } |
Output :0 |
396. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public class Manager { public static void main(String [] args) { B b1 = new C(); A a1 = b1; B b2 = (B)a1; System.out.println(b1.k); } } |
Output :CTE (Compile Time Error) |
397. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public class Manager { public static void main(String [] args) { A a1 = new B(); A a1 = a; B b2 = (B)a1; System.out.println(b2.j); } } |
Output :CTE (Compile Time Error) |
398. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public class Manager { public static void main(String [] args) { A a1 = new B(); C c1 = (C)a1; System.out.println(a1.i); System.out.println(c1.i); System.out.println(c1.j); System.out.println(c1.k); B b1 = (B)a1; A a2 = b1; System.out.println(b1.i); System.out.println(b1.j); System.out.println(b1.k); System.out.println(a2.i); System.out.println(a2.j); } } |
Output :CTE (Compile Time Error) |
399. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public class Manager { public static void main(String [] args) { A a1 = new B(); A a2 = new (A)(A)a1; B b1 = (B)a2; C c1 = (C)b1; B b2 = (C)a1; System.out.println(a1.i); System.out.println(c1.k); System.out.println(b2.j); System.out.println(a2.i); } } |
Output :CCE (Class Cast Exception) |
400. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public Class Manager { public static void main(String [] args) { C c1 = (C) new A(); B b1 = (C) new B(); C c1 = (B)(C) new A(); } } |
Output :CTE (Compile Time Error) |
401. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public Class Manager { public static void test(A a1) { System.out.println(a1.i); System.out.println(a1.j); System.out.println(a1.k); } public static void test(B b1) { System.out.println(b1.i); System.out.println(b1.j); System.out.println(b1.k); } public static void main(String [] args) { A a1 = new B(); test(a1); test((B)a1); } } |
Output :CTE (Compile Time Error) |
402. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public Class Manager { public static void test1(A a1) { System.out.println(a1.i); } public static void test2(B b1) { System.out.println(b1.i); System.out.println(b1.j); } public static void test3(C c1) { System.out.println(c1.i); System.out.println(c1.j); System.out.println(c1.k); } public static void main(String [] args) { A a1 = new C(); test1(a1); test2((B)a1); test3((C)a1); test1((B)a1); test2((C)a1); test3((C)a1); test1((B)(A)(C)a1); test2((B)(C)a1); test3((B)(C)(A)a1); } } |
Output :CTE (Compile Time Error) |
403. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public Class Manager { public static void test(A a1) { B b1 = (B)a1; C c1 = (C)a1; System.out.println(b1.j); System.out.println(c1.k); } public static void main(String [] args) { A a1 = new A(); test(a1); B b1 = new B(); test(b1); C c1 = new C(); test(c1); A a11 = new A(); test(a11); } } |
Output :CTE (Compile Time Error) |
404. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public Class Manager { public static void test1(A a1) { System.out.println("A"); } public static void test1(B b1) { System.out.println("B"); } public static void test1(C c1) { System.out.println("C"); } public static void main(String [] args) { A a1 = new C(); test1(a1); test1((B)a1); test1((C)a1); test1((B)(A)(C)(A)(B)a1); } } |
Output :AB C B |
405. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public class Manager { public static void test1(B b1 ) { System.out.println("B"); } public static void main(String [] args) { A a1 = new C(); test1(a1); test1((B)a1); test1((C)a1); test1((B)(A)(C)(A)(B)a1); } } |
Output :CTE (Compile Time Error) |
406. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public class Manager { public static void test1(B b1) { System.out.println("B"); } public static void main(String [] args) { A a1 = new C(); test1((B)a1); test1((C)a1); test1((B)(A)(C)(A)(B)a1); } } |
Output :BB B |
407. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public Class Test { public void test(double d) { System.out.println("Double"); } public void test(Object obj) { System.out.println("Object"); } } public class Manger { public static void main(String [] args) { Test t = new Test(); t.test(10); t.test(10.0); t.test(new A()); t.test(new B()); t.test(new C()); t.test(new Object()); t.test((B)new C()); } } |
Output :DoubleDouble Object Object Object Object Object |
408. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public Class Manager { public static void main(String [] args) { A a1 = new C(); B b1 = (B)a1; C c1 = (C)b1; C c2 = (C)a1; C c3 = (C)(B)a1; C c4 = (C)(B)(A)(B)(C)b1; System.out.println(b1.j); } } |
Output :0 |
409. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public Class Manager { public static void main(String [] args) { A a1 = new B(); C c1 = (C)a1; System.out.println(a1.i); System.out.println(c1.j); System.out.println(c1.j); System.out.println(c1.k); B b1 = (B)a1; System.out.println(b1.i); System.out.println(b1.j); System.out.println(b1.k); System.out.println(b1.i); System.out.println(b1.j); } } |
Output :CTE (Compile Time Error) |
410. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public class Manager { public static void main(String [] args) { A a1 = new A(); B b1 = (B)a1; C c1 = (C)a1; System.out.println(b1.i); System.out.println(b1.j); System.out.println(b1.j); System.out.println(a1.i); System.out.println(a1.j); } } |
Output :CTE (Compile Time Error) |
411. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public Class Manager { public static void main(String [] args) { A a1 = new A(); A a2 = a1; B b1 = (B)a2; C c1 = (C)a1; B b2 = (B)a1; System.out.println(a1.i); System.out.println(c1.k); System.out.println(b2.j); System.out.println(a2.i); System.out.println(a2.i); } } |
Output :CCE (Class Cast Exception) |
412. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public class Manager { public static void main(String [] args) { C c1 = (C)new A(); B b1 = (C)new B(); C c1 = (B)(C)new A(); } } |
Output :CTE (Compile Time Error) |
413. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public class Manager { public static void main(String [] args) { C c1 = (C)new A(); B b1 = (C)new B(); } } |
Output :CCE (Class Cast Exception) |
414. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public class Manager { public static void test(A a1) { System.out.println(a1.i); System.out.println(a1.j); System.out.println(a1.k); } public static void test(B b1) { System.out.println(b1.i); System.out.println(b1.j); System.out.println(b1.k); } public static void main(String [] args) { A a1 = new B(); test(a1); test((B)a1); } } |
Output :CTE (Compile Time Error) |
415. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public Class Manager { public static void test1(A a1) { System.out.println(a1.i); } public static void test2(B b1) { System.out.println(b1.i); System.out.println(b1.j); } public static void test3(C c1) { System.out.println(c1.i); System.out.println(c1.j); System.out.println(c1.k); } public static void main(String [] args) { A a1 = new C(); test1(a1); test2((B)a1); test3((C)a1); test1((B)a1); test2((C)a1); test3((B)a1); test1((B)(A)(C)a1); test2((B)(C)a1); test3((B)(C)(A)a1); } } |
Output :CTE (Compile Time Error) |
416. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public Class Manager { public static void test1(A a1) { B b1 = (B)a1; C c1 = (C)a1; System.out.println("b1.j"); System.out.println("c1.k"); } public static void main(String [] args) { A a1 = new C(); test1(a1); B b1 = new B(); test1(b1); C c1 = new C(); test1(c1); A a11 = new A(); test1(a1); } } |
Output :b1.jc1.k CCE (Class Cast Exception) |
417. Programpackage com.jaladhi;public class A { } public class B extends A { } public class C extends B { } public class D extends C { } public class Util { public static void test(Object o1) { if(o1 instanceof A) { System.out.println("Can Be Converted to A"); } if(o1 instanceof B) { System.out.println("Able to Convert to B"); } if(o1 instanceof C) { System.out.println("Able to Convert to C"); } } } public Class Manager { public static void test1(A a1) { B b1 = (B)a1; C c1 = (C)a1; System.out.println("b1.j"); System.out.println("c1.k"); } public static void main(String [] args) { A a1 = new A(); A a2 = new B(); A a3 = new C(); B b1 = new B(); B b2 = new C(); Util.test(a1); System.out.println("-------------------"); Util.test(a2); System.out.println("-------------------"); Util.test(a3); System.out.println("-------------------"); Util.test(b1); System.out.println("-------------------"); Util.test(b2); System.out.println("-------------------"); Util.test(new D()); } } |
Output :Can Be Converted to A------------------- Can Be Converted to A Able to Convert to B ------------------- Can Be Converted to A Able to Convert to B Able to Convert to C ------------------- Can Be Converted to A Able to Convert to B ------------------- Can Be Converted to A Able to Convert to B Able to Convert to C ------------------- Can Be Converted to A Able to Convert to B Able to Convert to C |
418. Programpackage com.jaladhi;public class A { } public class B extends A { } public class C extends B { } public class D extends C { } public class Util { public void test(Object o1) { if(o1 instanceof A) { System.out.println("Can be converted to A"); } if(o1 instanceof B) { System.out.println("Can be converted to B"); } if(o1 instanceof C) { System.out.println("Can be converted to C"); } } public class Manager { public static void main(String [] args) { A a1 = new A(); A a2 = new B(); A a3 = new C(); B b1 = new B(); B b2 = new C(); Util.test(a1); System.out.println("--------------"); Util.test(a2); System.out.println("--------------"); Util.test(a3); System.out.println("--------------"); Util.test(b1); System.out.println("--------------"); Util.test(b2); System.out.println("--------------"); Util.test(new D()); } } |
Output :CTE (Compile Time Error) |
419. Programpackage com.jaladhi;public class A { } public class B extends A { } public class C extends B { } public class Manager extends C { public static void main(String [] args) { Object all[] = new Object[5]; Object o1 = new Object(); A a1 = new A(); B b1 = new B(); C c1 = new C(); Manager m1 = new Manager(); all[0] = m1; all[1] = c1; all[2] = b1; all[3] = a1; all[4] = o1; Object obj = null; for(int i = 0; i < all.length; i++) { obj = all[i]; if(obj instanceof Object) { System.out.println("Object Type"); } if(obj instanceof A) { System.out.println("A Type"); } if(obj instanceof B) { System.out.println("B Type"); } if(obj instanceof C) { System.out.println("C Type"); } if(obj instanceof Manager) { System.out.println("Manager Type"); } } } } |
Output :Object TypeA Type B Type C Type Manager Type Object Type A Type B Type C Type Object Type A Type B Type Object Type A Type Object Type |
420. Programpackage com.jaladhi;public class A { int i; } public class B extends A { int j; } public class C extends B { int k; } public class Manager { public static void main(String [] args) { A a1 = new A(); A a2 = new B(); C c1 = new C(); A a = new c(); A a3 = new B(); B b1 = (B) a3; System.out.println(a1.i); System.out.println(c1.k); System.out.println(a2.i); System.out.println(a2.i); } } |
Output :00 0 0 |
421. Programpackage com.jaladhi;public class A { void test() { Systematization(“A”); } } public class B extends A { void test() { Systematization(“B”); } } public class C extends B { void test() { Systematization(“C”); } } public class Utils { static void main(A a) { a.test(); } } public class Manager { public static void main(String args [] ) { A a1 = new A(); B b1 = new B(); C c1 = new C(); Utils u = new Utils(); u.method(a1); u.method(b1); u.method(c1); } } |
Output :AB C |
422. Programpackage com.jaladhi;import bsh.unit.util; public class A { int i = 10; } public class B extend A { int j = 20; } public class Manager { public static video main(String [] args ) { A a1 = new A(); System.out.println(a1.i); System.out.println(a1.j); B b1 = new B(); System.out.println(b1.i); System.out.println(b1.j); } } |
Output :Compiler Time Error |
423. Programpackage com.jaladhi;public abstract class Person { abstract void walkingStyle(); } public class Male extends Person { void walkingStyle () { System.out.println(“Special Type”); } } public class Female extends Person { void walkingStyle () { System.out.println(“Normal Type”); } } public class Utils { static void checkWalkingStyle (Person p) { p. walkingStyle(); } } public class Manager { public static void main(String args [] ) { Male m1 = new Male(); Female f1 = new Female(); Utils.checkWalkingStyle(m1); Utils.checkWalkingStyle(f1); } } |
Output :Special TypeNormal Type |
424. Programpackage com.jaladhi;public class A { int i = 10; } public class B extends A { int j = 20 } public class Utils { void test(A a1) { System.out.println(a1.i); System.out.println(a1.j); } } public class Manager { public static void main(String args [] ) { A a1 = new A(); B b1 = new B(); Utils u = new Utils(); u.test(a1); u.test(b1); } } |
Output :Compiler Time Error |