Give an example of a superclass and subclass

Assignment Help Basic Computer Science
Reference no: EM132007647

What does the super keyword represents and where can it be used? Give an example of a superclass and subclass. Be sure to make all the instances variables of the super class private. Include at least one constructor in each class and ensure that the constructor of the subclass calls the constructor of the superclass. Also include a toString method in both classes that returns the values of the instance variables with appropriate labels. Ensure that the toString method of subclass calls the toString method of the superclass so that the string returned contains the values of all the inherited instance variables.

Here is what I have:

package burger;

public class Burger extends Cheeseburger { //subclass

  public void printOrder () {

    super.printOrder();

    System.out.println("This burger is good.");

  }

  public static void main(String[] args) {

    Burger testSuper = new Burger ();

    testSuper.printOrder();

  }

}

........................................................

package burger;

public class Cheeseburger { //superclass

  public void printOrder () {

    System.out.println("This cheeseburger is good.");

  }

}

Reference no: EM132007647

Questions Cloud

What skills or vocal image were examined well : What skills or vocal image were examined well by your classmate? Do you agree with them and why? Were any skills or observations overlooked?
Determining the cyber crime perspective : Which should you be most concerned about from a cyber crime perspective: organized crime, nation-states or individual rogue adversaries
Identify the parts of the model for improving interpersonal : In evaluating personality types and cognitive styles, which types/styles do you consider important for identifying with personality differences among people?
Information system from development into production : What factors might help your team decide when to move a new or updated information system from development into production?
Give an example of a superclass and subclass : What does the super keyword represents and where can it be used? Give an example of a superclass and subclass.
Describe how the firm can hedge transaction risk associated : Describe how the firm can hedge the transaction risk associated with the payment using a currency option.
Customers served and the total rental income : Inside a second group box to display the customers served and the total rental income after discount.
What type of lymphocyte generates antibodies : What type of lymphocyte generates antibodies? What cell surface molecule is a characteristic marker for T helper cells
Preferred stock and common equity financing : A company expects to earn $16 million in income this coming year. Its target capital structure is 30% debt, 15% preferred stock, and 55% common equity financing

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Review case of the file concatenation

File concatenation: Many operating systems allow one to concatenate files. Design a class called Text Document that reads the contents of a text file only.

  Prove that this language is nonregular

Build a PM that accepts the language of all words that have an a as the middle letter. (These words obviously must have odd length).

  Alternative paths based on variable conditions

The use of the if statement allows your program to take alternative paths based on variable conditions.

  Correlated groups and the t-test for single samples

What is the difference between the t-test for correlated groups and the t-test for single samples?

  How the system processes behave

How well would a cluster-based analysis mechanism for anomaly-based intrusion detection work with this system? Justify your answer.

  General area of network security is obviously of enormous

The general area of network security is obviously of enormous corporate and national importance. And there's no doubt that intrusion detection and prevention is a principal concern. Lately there have been a number of concerted security attacks on maj..

  Discuss the points and tabulate the strengths and weakness

Please discuss the points and tabulate the strengths and weaknesses

  Create the inverse version of the number guesser

Create the inverse version of the number guesser program. In this version of the program, the user comes up with the number and the computer will 'guess' the user's number. Your algorithm should be able to find a number between 1 and 100 within seven..

  Parameters and return double in the method

Write a method called getPrice that takes no parameters and return double In the method body generate a random number between 1 and 50

  Imagine that you are the marketing manager

Imagine that you are the marketing manager for a U.S. manufacturer of disposable diapers. Your firm is considering entering the Brazilian market.

  Create a visual logic flowchart that parallels pseudocode

Create a Visual Logic flowchart that parallels this pseudocode.

  Contents of an office

You are working on a project to move the contents of an office from one location to another. you will need to move heavy furniture like desks, filling cabinets .what are the potential risks ? formulate a risk management plan for the projects and ..

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