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  
Izaganag Izaganag
wrote...
Posts: 686
Rep: 2 0
8 years ago
What is printed by the following code?  Consider the polymorphic invocation.
   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
Figure
Figure
B) Figure
Rectangle
Box
C) Rectangle
Box
D) Syntax error.  This code won't compile or execute
E) none of the above
Textbook 
Java Software Solutions: Foundations of Program Design

Java Software Solutions: Foundations of Program Design


Edition: 7th
Authors:
Read 184 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
That makes life a whole lot easier, thank you for answering.
wrote...
8 years ago
Guys, you see that "vote as best answer" button below the answer, CLICK IT Slight Smile Slight Smile
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  1300 People Browsing
Related Images
  
 1278
  
 374
  
 840
Your Opinion
What percentage of nature vs. nurture dictates human intelligence?
Votes: 431

Previous poll results: Do you believe in global warming?