× Didn't find what you were looking for? Ask a question
Top Posters
Since Sunday
5
a
5
k
5
c
5
B
5
l
5
C
4
s
4
a
4
t
4
i
4
r
4
New Topic  
DePeet DePeet
wrote...
Posts: 338
Rep: 0 0
6 years ago
What is the output of the following code?
   public class Inherit
   {
      class Figure
      {
         void display()
         {
            System.out.println("Figure");
         }
      }
      class Rectangle extends Figure
      {
         void display()
         {
            System.out.println("Rectangle");
         }
      }
      class Box extends Figure
      {
         void display()
         {
            System.out.println("Box");
         }
      }
      Inherit()
      {
         Figure f = new Figure();
         Rectangle r = new Rectangle();
         Box b = new Box();
         f.display();
         f = r;
         f.display();
         f = b;
         f.display();
      }
      public static void main(String[] args)
      {
         new Inherit();
      }
   }
a.   Figure
Rectange
Box
b.   Rectangle
Box
c.   Figure
Figure
Figure
d.   Syntax error; this code won't compile
e.   None of these
Read 55 times
1 Reply
Replies
Answer verified by a subject expert
se7ense7en
wrote...
Posts: 327
Rep: 0 0
6 years ago
Sign in or Sign up in seconds to unlock everything for free
1

Related Topics

DePeet Author
wrote...

6 years ago
This site is awesome
wrote...

Yesterday
You make an excellent tutor!
wrote...

2 hours ago
Thank you, thank you, thank you!
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  1324 People Browsing
Related Images
  
 170
  
 146
  
 296
Your Opinion