java homework 1. Inheritance is also known as the a. has-a relationship. b. know
ID: 3673452 • Letter: J
Question
java homework
1. Inheritance is also known as the
a. has-a relationship.
b. knows-a relationship.
c. uses-a relationship.
d. is-a relationship.
2.Which of the following is a superclass/subclass (parent/child) relationship? Select all that apply.
Select one or more:
a. parent- Vehicle, child- Boat
b. parent- Dog, child- Poodle
c. parent- Dog, child- Cat
d. parent- Employee, child- Person
e. parent- Employee, child- Hourly Employee
3. Which of the following is true about inheritance? Select all that apply.
Select one or more:
a. A class can directly inherit from (extend) the Object class.
b. A parent class's instance variables should be declared private to enforce good principles of object-oriented programming (such as encapsulation).
c. A child class's instance variables should be declared private to enforce good principles of object-oriented programming (such as encapsulation).
d. All methods and constructors of a parent class are inherited by the child class.
e. You should override all methods from the parent class to enforce good principles of object-oriented programming (such as encapsulation).
f. You should use the @Override annotation whenever you override a method.
e. All instance variables in a parent class can be directly accessed in a child class.
4. Which of the following keywords allows a child class to access a parent's method even when the child has overridden the parent's method?
Select one:
a. base
b. this
c. public
d. protected
e. super
f. none of the above
Explanation / Answer
1) d
Inheritance represents the IS-A relationship, also known as parent-child relationship.
2) a vehicle is a parent and boat is child boat is a vehicle
b poodle is a breed of dog.
e employee is class and hourly employee is su class of employee
3) d,
4) e
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.