Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started