× Didn't find what you were looking for? Ask a question
Top Posters
Since Sunday
c
6
r
4
c
3
m
3
h
3
1
3
n
3
s
3
d
3
c
3
r
3
e
3
New Topic  
Stromile Stromile
wrote...
Posts: 299
Rep: 0 0
6 years ago
What is the output of the following code?
public class Inherit
   {
      abstract class Figure
      {
         void display()
         {
            System.out.println("Figure");
         }
      }
      abstract class Rectangle extends Figure
      {
      }
      class Box extends Rectangle
      {
         void display()
         {
            System.out.println("Rectangle");
         }
      }
      Inherit()
      {
         Figure f = (Figure) new Box();
         f.display();
         Rectangle r = (Rectangle) f;
         r.display();
      }
      public static void main(String[] args)
      {
         new Inherit();
      }
   }
a.   Rectangle
Rectange
b.   Rectangle
Figure
c.   Figure
Rectangle
d.   Figure
Figure
e.   None of these
Read 86 times
1 Reply
Replies
Answer verified by a subject expert
StingerStinger
wrote...
Posts: 310
Rep: 4 0
6 years ago
Sign in or Sign up in seconds to unlock everything for free
1

Related Topics

Stromile Author
wrote...

6 years ago
Thanks
wrote...

Yesterday
Thanks
wrote...

2 hours ago
Correct Slight Smile TY
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  1257 People Browsing
Related Images
  
 726
  
 311
  
 60
Your Opinion
Which is the best fuel for late night cramming?
Votes: 231