Top Posters
Since Sunday
New Topic  
Izaganag Izaganag
wrote...
Posts: 686
Rep: 2 0
8 years ago
What is printed?

   public class Inherit
   {

      class Figure
      {
         void display( )
         {
            System.out.println("Figure");
         }
      }

      class Rectangle extends Figure
      {
         void display( )
         {
            System.out.println("Rectangle");
         }
      }

      class Box extends Rectangle
      {
         void display( )
         {
            System.out.println("Box");
         }
      }

      Inherit( )
      {
         Figure f = new Figure( );
         Rectangle r = new Rectangle( );
         Box b = new Box( );
         f.display( );
         f = r;
         ((Figure) f).display( );
         f = (Figure) b;
         f.display( );
      }

      public static void main(String[ ] args)
      {
         new Inherit( );
      }
   }
A) Figure
Rectangle
Box
B) Figure
Rectangle
Figure
C) Rectangle
Figure
D) Figure
Figure
Figure
E) none of the above
Textbook 
Java Software Solutions: Foundations of Program Design

Java Software Solutions: Foundations of Program Design


Edition: 7th
Authors:
Read 228 times
3 Replies
Replies
Answer verified by a subject expert
habibtihabibti
wrote...
Top Poster
Posts: 1486
8 years ago
Sign in or Sign up in seconds to unlock everything for free
More solutions for this book are available here
1

Related Topics

Izaganag Author
wrote...
8 years ago
I regret taking this computer science course. Should just stick to history Face with Stuck-out Tongue Thanks for your help.
wrote...
8 years ago
Give me a shout if you need anymore help.
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  1235 People Browsing
Related Images
  
 107
  
 147
  
 392