4) Show the output of following program: 1 public class Test { A WNPI 2 3 4 } public static void main(String[] args) { A
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
4) Show the output of following program: 1 public class Test { A WNPI 2 3 4 } public static void main(String[] args) { A
2) Show the output of the following code public class Test { public static void main(String[] args) { new Person().printPerson(); new Student ().printPerson(); } class Student extends Person { @Override public String getInfo() { return "Student"; } } } } class Person { public String getInfo() { return "Person"; } public void print Person () { System.out.println(getInfo()); } public class Test { public static void main(String[] args) { } } } class Student extends Person { private String getInfo() { return "Student"; } } new Person().printPerson(); new Student ().printPerson(); class Person { private String getInfo() { return "Person"; } public void print Person () { System.out.println(getInfo()); } (b)
3) What is the output of running the class C in (a)? What problem arises in compiling the program in (b)? class A { public A() { class B extends A { } } System.out.println( "A's no-arg constructor is invoked"); public class C { public static void main(String[] args) { B b = new B(); } class A { } } public A(int x) { class B extends A { public B() { } } } public class C { public static void main(String[] args) { B b = new B(); } (b)