4) Show the output of following program: 1 public class Test { A WNPI 2 3 4 } public static void main(String[] args) { A

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
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

Post by answerhappygod »

4 Show The Output Of Following Program 1 Public Class Test A Wnpi 2 3 4 Public Static Void Main String Args A 1
4 Show The Output Of Following Program 1 Public Class Test A Wnpi 2 3 4 Public Static Void Main String Args A 1 (28.89 KiB) Viewed 32 times
4 Show The Output Of Following Program 1 Public Class Test A Wnpi 2 3 4 Public Static Void Main String Args A 2
4 Show The Output Of Following Program 1 Public Class Test A Wnpi 2 3 4 Public Static Void Main String Args A 2 (140.25 KiB) Viewed 32 times
4 Show The Output Of Following Program 1 Public Class Test A Wnpi 2 3 4 Public Static Void Main String Args A 3
4 Show The Output Of Following Program 1 Public Class Test A Wnpi 2 3 4 Public Static Void Main String Args A 3 (67.89 KiB) Viewed 32 times
4) Show the output of following program: 1 public class Test { A WNPI 2 3 4 } public static void main(String[] args) { A a = new A (3); 5} 6 7 class A extends B { public A (int t) { 8 9 10 14 15 } System.out.println("A's constructor is invoked"); 11} 12 13 class B { public B() { System.out.println("B's constructor is invoked"); 16 17 } Is the no-arg constructor of Object invoked when new A(3) is invoked? }
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)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply