0% found this document useful (0 votes)
98 views10 pages

Quiz5 1

This document summarizes the results of a quiz on object-oriented programming concepts taken in an online course. It includes 16 multiple choice questions testing topics like inheritance, encapsulation, and class relationships. The student scored 16 out of 16 points by answering all questions correctly. The quiz was open for one hour and the student completed it in under 20 minutes, demonstrating a strong understanding of fundamental OOP principles.

Uploaded by

James Podlewski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views10 pages

Quiz5 1

This document summarizes the results of a quiz on object-oriented programming concepts taken in an online course. It includes 16 multiple choice questions testing topics like inheritance, encapsulation, and class relationships. The student scored 16 out of 16 points by answering all questions correctly. The quiz was open for one hour and the student completed it in under 20 minutes, demonstrating a strong understanding of fundamental OOP principles.

Uploaded by

James Podlewski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Module 5: Quiz 5.

1
 Due Sep 27 at 2:59am

 Points 16

 Questions 16

 Available until Sep 28 at 2:59am

 Time Limit 60 Minutes

Attempt History
Attempt Time Score

LATEST Attempt 1 16 minutes 16 out of 16


Score for this quiz: 16 out of 16
Submitted Sep 26 at 7:21pm
This attempt took 16 minutes.

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?

calls the method super as defined in the current class

calls the method super as defined in the current class'parent class

calls the method super as defined in java.lang

calls the constructor as defined in the current class


Correct!

calls the constructor as defined in the current class'parent class

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;
...
}

public class A2 extends A1


{
protected int a;
private int b;
...
}

public class A3 extends A2


{
private int q;
...
}

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?

A computer can be a mainframe or a PC

A PC can be a desktop or a laptop


Correct!

A laptop is both a PC and a portable device

A portable device is a lightweight device

Macintosh and IBM PC are both types of PCs

Question 8
1 / 1 pts
Using the reserved word, super, one can
Correct!

access a parent class' constructor(s)

access a parent class' private methods and private instance data

access a child class'constructor(s)


access a child class' private methods and private instance data

access parent class' methods and child class' methods

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!

change private methods and instance data to be protected

change public methods and instance data to be protected

change all methods to be protected

change the class to be protected

none of the above, the programmer should not change anything

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 A2 extends A1


{
protected int a;
private int b;
...
}

public class A3 extends A2


{
private int q;
...
}

Which of the following is true with respect to A1, A2 and A3?

A1 is a subclass of A2 and A2 is a subclass of A3


Correct!

A3 is a subclass of A2 and A2 is a subclass of A1

A1 and A2 are both subclasses of A3

A2 and A3 are both subclasses of A1

A1, A2 and A3 are all subclasses of the class A


Question 12
1 / 1 pts
Consider the following partial class definitions:

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;
...
}

Which of the following lists of instance data are accessible in A3?

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

permit access to the protected item by any static class

permit access to the protected item by any parent class

ensure that the class can not throw a NullPointerException

define abstract elements of an interface

Question 14
1 / 1 pts
Why shouldn't an abstract method be declared final?

There's nothing wrong with doing so


Correct!

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

None of the above

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

Quiz Score: 16 out of 16


PreviousNext

You might also like