Search Header Logo

Inheritance Quiz

Authored by Rose Malaborbor

Education

University

Used 1+ times

Inheritance Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

5 questions

Show all answers

1.

MULTIPLE SELECT QUESTION

1 min • 3 pts

Which of the following statements about inheritance in Java is/are true?

Inheritance allows a subclass to inherit fields and methods from its superclass.

Java supports multiple inheritance.

The keyword "extends" is used to indicate that a class is a subclass of another class.

Constructors are not inherited from the superclass.

2.

MULTIPLE CHOICE QUESTION

1 min • 3 pts

A car dealership needs a program to store information about the cars for sale. For each car, they want to keep track of the following information: number of doors (2 or 4), whether the car has air conditioning, and its average number of miles per gallon. Which of the following is the best design?

Use four unrelated classes: Car, Doors, AirConditioning, and MilesPerGallon.

Use classes: Doors, AirConditioning, and MilesPerGallon, each with a subclass Car.

Use a class Car, with fields: numDoors, hasAir, and milesPerGallon.

Use a class Car, with superclasses of Doors, AirConditioning, and MilesPerGallon.

3.

MULTIPLE CHOICE QUESTION

3 mins • 3 pts

A bookstore is working on an on-line ordering system. For each type of published material (books, movies, audio tapes) they need to track the id, title, author(s), date published, and price. Which of the following would be the best design?

Create one class PublishedMaterial with the requested fields plus type.

Create classes Book, Movie, and AudioTape with the requested fields.

Create one class BookStore with the requested fields plus type.

Create the class PublishedMaterial with child classes of Book, Movie, and AudioTape.

4.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

In a Multi-Level Inheritance in Java, the last subclass inherits methods and properties of ____.

Only one immediate Superclass

Few classes above it.

All classes above it

None of the choices

5.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Which of the following is an example of hierarchical inheritance in Java?

A Car class that inherits from a Vehicle class, and a Truck class that inherits from the Car class.

A Circle class that inherits from a Shape class, and a Shape class that inherits from the Rectangle class.

A Person class that inherits from a Student class, and a Teacher class that inherits from the Person class.

A Dog class that inherits from an Animal class, and a Cat class that also inherits from the Animal class.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?