What is printed out by the following


Question 1. What is printed out by 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( )
{
Rectangle r = new Rectangle( );
Figure f = new Figure( );
Box b = new Box( );
r.display( );
r = f;
r.display( );
r = b;
r.display( );
}
public static void main(String[ ] args)
{
new Inherit( );
}
}

Question 2. Complete the missing code.
import java.util.Random;
public class LinearArray
{
private int[] data;
private static Random generator = new Random();

public LinearArray(int size)
{
data = new int[size];

//write the code here to fill the data (instance variable from above) array with //random integers in range 100-999
}

// write the code here to perform a linear search on the data (instance variable
// from above)
}

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: What is printed out by the following
Reference No:- TGS01087082

Expected delivery within 24 Hours