Question: 2. Consider the code shown below. It contains a syntax error, preventing successful compilation and execution. What is the error? public class Inherit {

2. Consider the code shown below. It contains a syntax error, preventing successful compilation and execution. What is the error? public class Inherit { class Figure { void display() { } } } class Rectangle extends Figure { { System.out.println("Figure"); final 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(); r.display(); b.display(); } public static void main(String[] args) } { } new Inherit (); 3. Explain briefly how the System.out.println() method can handle a wide variety of objects. 4. What is required on the data for binary search to work?
Step by Step Solution
3.40 Rating (163 Votes )
There are 3 Steps involved in it
public class Inherit Missing method declaration for displayi in the Figure class class Figure void d... View full answer
Get step-by-step solutions from verified subject matter experts
