Question: Question 1. Assume the following classes are each defined in their own java files and compile public class A { public void display() { System.out.println(A's
Question 1.
Assume the following classes are each defined in their own java files and compile public class A { public void display() { System.out.println("A's display"); } } public class B extends A { public void display() { System.out.println("B's display"); } } public class C extends A { public void display() { System.out.println("C's display"); } } public class D { public static void main(String[] args) { A a = new C(); System.out.print("A" + (a instanceof A) + " B " + (a instanceof B) + " C " + (a instanceof C) + " Obj " + (a instanceof Object)); } } What is output when I run D?
Question 2. Using the MyStack class, what will be the result of running D? public class D { public static void main(String[] args) { MyStack mstack = new MyStack(); Object top = mstack.pop(); System.out.print(top); } } |
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
