Question: 11. The relationship between a child (sub) class and a parent (super) class is referred to as a(n) ____ relationship. (2 points) abstract has-a is-a

11.

The relationship between a child (sub) class and a parent (super) class is referred to as a(n) ____ relationship. (2 points)

abstract

has-a

is-a

polymorphism

was-a

12.

The process of determining which method in a class hierarchy should execute is known as (2 points)

is-a

has-a

inheritance

parent class

polymorphism

13.

Consider the following code: public class A1 { public int x; private int y; ... } public class A2 extends A1 { public int a; private int b; ... } public class A3 extends A2 { private int q; ... } Which of the following sets of instance variables are directly accessible in class A2? (2 points)

a, b

x, a, b

x, y, a, b

x, y, a, b, q

y, a, b

14.

Consider the following code: public class A1 { public int x; private int y; ... } public class A2 extends A1 { public int a; private int b; ... } public class A3 extends A2 { private int q; ... } Which of the following is true regarding the use of instance variable y in class A1? (2 points)

It is directly accessible only in A1

It is directly accessible only in A3

It is directly accessible in A1 and A2

It is directly accessible in A1, A2, and A3

It is not directly accessible in any of the three classes

15.

Consider the following code: public class B1 { private int i; private int j; ... } public class B2 extends B1 { private int m; private int n; ... } public class B3 extends B2 { private int z; ... } Which of the following sets of instance variables are directly accessible in class B3? (2 points)

i, j, m, n

i, j, m, n, z

i, j, z

m, n, z

z

16.

Consider the following code: public class B1 { private int i; private int j; ... } public class B2 extends B1 { private int m; private int n; ... } public class B3 extends B2 { private int z; ... } Which of the following is true regarding the use of instance variable j in class B1? (2 points)

It is directly accessible only in B1

It is directly accessible only in B2

It is directly accessible only in B3

It is directly accessible in B1 and B2

It is directly accessible in B1, B2, and B3

17.

The instruction super(); in a child class does which of the following? (2 points)

Invokes the constructor as defined in the current class.

Invokes the constructor as defined in the current class's parent class.

Invokes the method super as defined in java.lang.ArrayList.

Invokes the method super as defined in the current class.

Invokes the method super as defined in the current class's parent class.

18.

All classes in Java are directly or indirectly subclasses of the _______ class. (2 points)

Object

Reference

String

this

Wrapper

19.

Assume the Student and Employee classes each extend the Person class. The Student class overrides the getMoney method in the Person class. Consider the following code: Person p1, p2, p3; int m1, m2, m3; p1 = new Person(); m1 = p1.getMoney(); // assignment 1 p2 = new Student(); m2 = p2.getMoney(); // assignment 2 p3 = new Employee(); m3 = p3.getMoney(); // assignment 3 The reference to getMoney in assignment 2 is to the ________ class. (2 points)

Child

Person

Student

Employee

this cannot be determined by examining the code

20.

Assume the Student and Employee classes each extend the Person class. The Student class overrides the getMoney method in the Person class. Consider the following code: Person p1, p2, p3; int m1, m2, m3; p1 = new Person(); m1 = p1.getMoney(); // assignment 1 p2 = new Student(); m2 = p2.getMoney(); // assignment 2 p3 = new Employee(); m3 = p3.getMoney(); // assignment 3 The reference to getMoney in assignment 3 is to the ________ class. (2 points)

Child

Employee

Person

Student

this cannot be determined by examining the code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!