Exam 9: Inheritance
Exam 1: Introduction64 Questions
Exam 2: Data and Expressions67 Questions
Exam 3: Using Classes and Objects49 Questions
Exam 4: Writing Classes53 Questions
Exam 5: Conditionals and Loops38 Questions
Exam 6: More Conditionals and Loops35 Questions
Exam 7: Object-Oriented Design44 Questions
Exam 8: Arrays45 Questions
Exam 9: Inheritance49 Questions
Exam 10: Polymorphism40 Questions
Exam 11: Exceptions39 Questions
Exam 12: Recursion55 Questions
Exam 13: Collections60 Questions
Select questions type
Example Code Ch 09-1
Consider the following class hierarchy:
-Refer to Example Code Ch 09-1: Y is a derived class of Z.

(True/False)
4.8/5
(33)
A derived class has access to all of the methods of the parent class, but only to the protected or public instance data of the parent class.
(True/False)
4.8/5
(34)
Explain the difference between implementing an interface and a derived class.
(Essay)
4.9/5
(33)
Aside from permitting inheritance, the visibility modifier protected is also used to
(Multiple Choice)
4.9/5
(33)
Example Code Ch 09-4
Given the following partial class definition:
public class A1
{
public int x;
private int y;
protected int z;
...
}
public class A2 extends A1
{
protected int a;
private int b;
...
}
public class A3 extends A2
{
private int q;
...
}
-Refer to Example Code Ch 09-4: Which of the following is true with respect to A1, A2, and A3?
(Multiple Choice)
4.9/5
(41)
One way to allow for user interactivity in a program is to use a dialog box.
(True/False)
4.9/5
(40)
Example Code Ch 09-6
Assume that Student, Employee and Retired are all extended classes of Person, and all four classes have different implementations of the method getMoney. Consider the following code where ... indicates the required parameters for the constructors:
Person p = new Person(...);
int m1 = p.getMoney(); // assignment 1
p = new Student(...);
int m2 = p.getMoney(); // assignment 2
if (m2 < 100000)
p = new Employee(...);
else if (m1 > 50000)
p = new Retired(...);
int m3 = p.getMoney(); // assignment 3
-Refer to Example Code Ch 09-6: The reference to getMoney() in assignment 2 is to the class
(Multiple Choice)
4.8/5
(38)
Example Code Ch 09-1
Consider the following class hierarchy:
-Refer to Example Code Ch 09-1: A is a derived class of X.

(True/False)
4.8/5
(33)
Example Code Ch 09-2
Assume that Poodle is a derived class of Dog and that Dog d = new Dog(...) and Poodle p = new Poodle(...) where the ... are the necessary parameters for the two classes.
-Refer to Example Code Ch 09-2: The assignment statement d = p; is legal even though d is not a Poodle.
(True/False)
4.9/5
(41)
The reserved word, extends, is used to denote a has-a relationship.
(True/False)
4.8/5
(35)
Java doesn't support multiple inheritance; but it does support the implementation of multiple interfaces.
(True/False)
4.8/5
(31)
Example Code Ch 09-6
Assume that Student, Employee and Retired are all extended classes of Person, and all four classes have different implementations of the method getMoney. Consider the following code where ... indicates the required parameters for the constructors:
Person p = new Person(...);
int m1 = p.getMoney(); // assignment 1
p = new Student(...);
int m2 = p.getMoney(); // assignment 2
if (m2 < 100000)
p = new Employee(...);
else if (m1 > 50000)
p = new Retired(...);
int m3 = p.getMoney(); // assignment 3
-Refer to Example Code Ch 09-6: The reference to getMoney() in assignment 1 is to the class
(Multiple Choice)
4.8/5
(34)
Example Code Ch 09-3
Consider the class Car and the subclass SportsCar. Car has instance data of currentSpeed, type, year, cost, model, color and methods of accelerate, brake, getGasMileage, getInsuranceRate and determineSpeed.
-Refer to Example Code Ch 09-3: What instance data and methods might you define for SportsCar that are not part of Car?
(Essay)
5.0/5
(36)
Example Code Ch 09-4
Given the following partial class definition:
public class A1
{
public int x;
private int y;
protected int z;
...
}
public class A2 extends A1
{
protected int a;
private int b;
...
}
public class A3 extends A2
{
private int q;
...
}
-Refer to Example Code Ch 09-4: Which of the following is true regarding the use of instance data y of class A1?
(Multiple Choice)
4.8/5
(36)
Which of the following is not a method of the Object class?
(Multiple Choice)
4.7/5
(37)
The protected visibility modifier provides the best possible encapsulation that permits inheritance.
(True/False)
4.7/5
(34)
Example Code Ch 09-6
Assume that Student, Employee and Retired are all extended classes of Person, and all four classes have different implementations of the method getMoney. Consider the following code where ... indicates the required parameters for the constructors:
Person p = new Person(...);
int m1 = p.getMoney(); // assignment 1
p = new Student(...);
int m2 = p.getMoney(); // assignment 2
if (m2 < 100000)
p = new Employee(...);
else if (m1 > 50000)
p = new Retired(...);
int m3 = p.getMoney(); // assignment 3
-Refer to Example Code Ch 09-6: The reference to getMoney() in assignment 3 is to the class
(Multiple Choice)
4.9/5
(42)
Consider a class Plane and three subclasses, Glider, PropPlane and Jet. What instance data that should be declared in Plane and what instance data should be declared in each of the three subclasses? Come up with at least 2 instance data unique to each of the four classes given that all instance data of Plane will be inherited into the subclasses.
(Essay)
4.9/5
(31)
Showing 21 - 40 of 49
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)