What is printed out by the following code

Assignment Help JAVA Programming
Reference no: EM13806833

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)
}

Reference no: EM13806833

Questions Cloud

What is a sampling distribution and how would you create one : What is a sampling distribution and how would you create one from a population? What is meant by sample proportion and sample mean? How does the concept of Central Limit Theorem apply to sampling?
What is the current price per share : Research newspaper, business magazine articles, or the Web to find computer companies whose stock is traded publicly. Choose a company and pretend to buy $1,000 of its stock. What is the current price per share
Environmental scan paper : Write a 1,050- to 1,400-word paper in which you complete the following:
What is one area that you feel is a professional strength fo : Many concepts have been covered during this class to give you an opportunity to delve into your professionalism in more depth. After reviewing the results of the survey, what is one area that you feel is a professional strength for you and one area t..
What is printed out by the following code : What is printed out by the following code
Important role in shaping individuals behavior : Organizational culture plays an important role in shaping individuals' behavior within organizations and, consequently, has a significant influence on organizational performance.  Consider the culture of an organization for which you currently or ..
Contrast the organizational transformation process : Compare and contrast the organizational transformation process presented in the previous lessons with the process of individual recruitment and radicalization outlined here. What are the primary synergies between the two
Most significant issue facing management : Write a 500-word essay on what you think is the most significant issue facing management today - and why. This may or may not be the same issue as the one you choose for your research case study; that is your choice.
What are some of benefits and limitations to using interview : What are some of the benefits and limitations to using interview as a research methodology

Reviews

Write a Review

JAVA Programming Questions & Answers

  Populate a one-dimensional array

Populate a one-dimensional array with the following grades in this order: 93, 61, 72, 45, 84, 51, 70, 83, 96, and 66. Use a loop to call a method from main() that adds

  Design and implementation of a hangman game

Design and Implementation of a Hangman game

  Java program for real estate agent

Write down java program for real estate agent. Program must perform the following tasks: ask users for average house price for the each of past 5 years for single family residence of 1500 square feet.

  Design a single class that expresses the commonality

Design a single class that expresses the commonality of these concepts.

  If there are 4 command line arguments

If there are 4 command line arguments (a b c filename.dat) then the engine should take a,b,c and store the resulting x1 and x2 in filename.dat working in silent mode (no use of screen)

  Prepare a program to triple each number in the list

Write a program that will read in a list of numbers, triple each number in the list and print the result - Write a program that will read in 2 numbers per line, and print the sum.

  Write a program to print all of the permutations

Write a program to print all of the permutations of the values 1, 2, 3, ..., n - Your program takes one argument from the command line, which as an integer n  that is the number of elements.

  Java application that reads a date in numeric form

Designand write a java application that reads a date in numeric form from a set of three fields and displays it in English within a label. Use appropriate buttons. For Example:

  Difference between the two following statements

What exactly is the difference between the two following statements and which is preferred, please provide details: 1) frame.setSize(400, 300); // Set JFrame Size

  Return only the rows where the shipdate

Write a SELECT statement that returns these columns from the Orders table:

  Explain how cookies are used to implement sessions

Describe a set of four methods that a queue would need to implement using a circular array and show the Java code to implement them if using an implementation given the outline definition below. Do not use any methods of the Collection classes.

  Write a program that displays a frame window w pixels wide

Write a program that displays a frame window W pixels wide and H pixels high. Use the Scanner to enter the values for W and H. The title of the frame is also entered by the user.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd