Data Structures and Algorithms in Java
Data Structures and Algorithms in Java
6th Edition
ISBN: 9781119278023
Author: Michael T. Goodrich; Roberto Tamassia; Michael H. Goldwasser
Publisher: Wiley Global Education US
Expert Solution & Answer
Book Icon
Chapter 2, Problem 11R

Explanation of Solution

Output of the code:

Create a main class Maryland that extends the State class and it includes printMe() to display the respective header in console.

// Create a class Maryland

public class Maryland extends State

{

  // Null constructor

  Maryland( )

  {

  }

  // Create a method

  public void printMe( )

  {

  System.out.println("Read it.");

  }

Create a main() function and create the objects for the class using new keyword and call the method printMe() to display the respective header.

  // Main function

  public static void main(String[ ] args)

  {

  // Create the objects for classes

  Region east = new State( );

  State md = new Maryland( );

  Object obj = new Place( );

  Place usa = new Region( );

/* Call the method printMe() using state class object.*/

  md.printMe( );

  // Call the method printMe() using object

  east.printMe( );

  // Call the method printMe() in Place class

  ((Place) obj).printMe( );

  //Assign the state class object to object class

  obj = md;

  // Call the method printMe() in maryland class

  ((Maryland) obj).printMe( );

  //Assign the place class object to object class

  obj = usa;

  // Call the method printMe() in place class

  ((Place) obj).printMe( );

  //Assign the state class object to place class

  usa = md;

  // Call the method printMe() in place class

  ((Place) usa).printMe( );

  }

}

Create a class State that extends the class Region and includes a method printMe() to display the header.

// Create a class that extends the Region

class State extends Region

{

  //Null constructor

  State( )

  {

  }

  //Create a method

  public void printMe( )

  {

  //Display the header

  System.out.println("Ship it.");

  }

}

Create a class Region that extends the class Place and includes a method printMe() to display the header...

Blurred answer
Students have asked these similar questions
1. Draw flow charts for each of the following;a) A system that reads three numbers and prints the value of the largest number.b) A system reads an employee name (NAME), overtime hours worked (OVERTIME), hours absent(ABSENT) and determines the bonus payment (PAYMENT).
Scenario You work for a small company that exports artisan chocolate. Although you measure your products in kilograms, you often get orders in both pounds and ounces. You have decided that rather than have to look up conversions all the time, you could use Python code to take inputs to make conversions between the different units of measurement. You will write three blocks of code. The first will convert kilograms to pounds and ounces. The second will convert pounds to kilograms and ounces. The third will convert ounces to kilograms and pounds. The conversions are as follows: 1 kilogram = 35.274 ounces 1 kilogram = 2.20462 pounds 1 pound = 0.453592 kilograms 1 pound = 16 ounces 1 ounce = 0.0283 kilograms 1 ounce = 0.0625 pounds For the purposes of this activity the template for a function has been provided. You have not yet covered functions in the course, but they are a way of reusing code. Like a Python script, a function can have zero or more parameters. In the code window you…
make a screen capture showing the StegExpose results
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning