Quiz5 1
Quiz5 1
1
Due Sep 27 at 2:59am
Points 16
Questions 16
Attempt History
Attempt Time Score
Question 1
1 / 1 pts
The protected visibility modifier provides the best possible encapsulation that permits
inheritance.
Correct!
True
False
Question 2
1 / 1 pts
The instruction super( ); does which of the following?
Question 3
1 / 1 pts
Consider the following class hierarchy and answer these questions.
Y is a derived class of Z.
True
Correct!
False
Question 4
1 / 1 pts
The relationship between a parent class and a child class is referred to as a(n) ________
relationship.
has-a
Correct!
is-a
was-a
instance-of
alias
Question 5
1 / 1 pts
Consider the following partial class definitions:
public class A1
{
public int x;
private int y;
protected int z;
...
}
Which of the following lists of instance data are accessible in class A2?
x, y, z, a, b
x, y, z, a
Correct!
x, z, a, b
z, a, b
a, b
Question 6
1 / 1 pts
The reserved word, extends, is used to denote a has-a relationship.
True
Correct!
False
Question 7
1 / 1 pts
Which of the following is an example of multiple inheritance?
Question 8
1 / 1 pts
Using the reserved word, super, one can
Correct!
Question 9
1 / 1 pts
If class AParentClass has a protected instance data x, and AChildClass is a derived class of
AParentClass, then AChildClass can access x but can not redefine x to be a different type.
True
Correct!
False
Question 10
1 / 1 pts
If a programmer writes a class wanting it to be extended by another programmer, then this
programmer should
Correct!
Question 11
1 / 1 pts
Consider the following partial class definitions:
public class A1
{
public int x;
private int y;
protected int z;
...
}
public class A1
{
public int x;
private int y;
protected int z;
...
}
x, y, z, a, b, q
a, b, q
a, q
Correct!
x, z, a, q
x, a, q
Question 13
1 / 1 pts
Aside from permitting inheritance, the visibility modifier protected is also used to
Correct!
permit access to the protected item by any class defined in the same package
Question 14
1 / 1 pts
Why shouldn't an abstract method be declared final?
final abstract methods cannot be overridden and they must be overridden if a concrete class ever
is to be instantiated
So long as the abstract method never actually is used in by any other method, there's no problem
with doing this
So long as the abstract method is declared in a Class (not an Interface), there's nothing wrong
with doing this
Question 15
1 / 1 pts
You may use the super reserved word to access a parent class' private members.
True
Correct!
False
Question 16
1 / 1 pts
Consider the following class hierarchy and answer these questions.
If A, B, Y and Z all contain the same instance data d1, then d1 should be declared in X and
inherited into Y, Z, A and B.
Correct!
True
False