This textbook is available atAmazon.com Logo
Java Programming 9th Edition

Java Programming (9th Edition)

Book Edition9th Edition
Author(s)Farrell
ISBN9781337397070
PublisherCengage
SubjectComputer Science
Learning about the Concept of Inheritance
TWO TRUTHS & A LIE
Extending Classes
TWO TRUTHS & A LIE
Overriding Superclass Methods
TWO TRUTHS & A LIE
Calling Constructors during Inheritance
TWO TRUTHS & A LIE
Accessing Superclass Methods
TWO TRUTHS & A LIE
Employing Information Hiding
TWO TRUTHS & A LIE
Methods You Cannot Override
TWO TRUTHS & A LIE
Chapter 10, Learning about the Concept of Inheritance, TWO TRUTHS & A LIE, Exercise 01
Page 472

TWO TRUTHS & A LIE

 

1. When you use inheritance in Java, you can create a new class that contains all the data and methods of an existing class.

2. When you use inheritance, you save time and reduce errors.

3. A class that is used as a basis for inheritance is called a subclass.

Explanation

Statement 3 can be modified to the following to make it true:

A class that is used as a basis for inheritance is called a superclass.


The subclass is the class that inherits attributes and methods from another class.

The superclass is the class that a subclass inherits from.


For example, you can have a Car class (subclass) that inherits attributes and methods from a Vehicle class (superclass).

Answer

1 and 2 are true.

3 is a lie.

Did you like this example?
Subscribe for full access
Page 472