Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions