You are on page 1of 4

1Wh

. at
doe
s it
me
an
to
inh
erit
a
clas
s?

Mark for Review


(1) Points

The subclass (or child class) gains access to any non-private methods and
variables of the superclass (or parent class). (*)
The access specifier has been set to private.
A way of organizing the hierarchy of classes.
Extending a method from a superclass.
Correct
2. Which is the most accurate description of the code reuse philosophy?

Mark for
Review
(1) Points

A programming philosophy that promotes stealing your classmates' code.


A programming philosophy that promotes having no concern about the
security of code.
A programming philosophy that promotes protecting data and hiding
implementation in order to preserve the integrity of data and methods.
A programming philosophy that promotes simpler, more efficient coding
by using existing code for new applications. (*)
Correct
3. What is a UML?

Mark for
Review
(1) Points

Unidentified Molding Level, the level of access permitted by the default


access specifier.
Unified Modeling Language, a standardized language for modeling
systems and structures in programming. (*)
Universal Model Light, a program that reads the brightness of any given
lightbulb.
None of the above.
Correct
4. What keyword is used to inherit a superclass?

Mark for
Review
(1) Points

new
public
extends (*)
this
Incorrect. Refer to Section 7 Lesson 4.
5. Which of the following correctly defines a superclass (or parent class)?

Mark for
Review
(1) Points

A class that inherits methods and fields from a more general class.
The most specific class of a hierarchy system of classes.
A class that passes down its methods to more specialized classes. (*)
A keyword that allows or restricts access to data and methods.
Correct
6. Which of the following correctly defines a subclass (or child class)?

Mark for
Review
(1) Points

A class that inherits methods and fields from a more general class. (*)
A keyword that allows or restricts access to data and methods.
A class that passes down its methods to more specialized classes.
The most general class of a hierarchy system.
Correct
7. Methods are generally declared as public so other classes may use them. True
or false?

Mark for
Review
(1) Points

True (*)
False
Correct
8. Which of the following correctly describes the use of the keyword super?

Mark for
Review
(1) Points

A keyword that restricts access to only inside the same class.

A keyword that allows subclasses to access methods, data, and


constructors from their parent class. (*)
A keyword that signals the end of a program.
A keyword that allows access from anywhere.
Correct
9. Which of the following is the proper way to set the public variable length of the
super class equal to 5 from inside the subclass?

Mark for
Review
(1) Points

super.length() = 5
super.length(5)
super.length = 5 (*)
super(length = 5)
Correct
10What is a hierarchy?
.

Mark for
Review
(1) Points

A programming philosophy that promotes simpler, more efficient coding


by using existing code for new applications.
A programming philosophy that promotes protecting data and hiding
implementation in order to preserve the integrity of data and methods.
A keyword that allows subclasses to access methods, data, and
constructors from their parent class.
A structure that categorizes and organizes relationships among ideas and
concepts of things with the most general at the top and the most specific
at the bottom. (*)
Correct
11Where should the constructor for a superclass be called?
.

Mark for
Review
(1) Points

Anywhere inside the subclass.


Inside the main method of the subclass.
The last line in the constructor of the subclass.
The first line of the constructor in the subclass. (*)
The super constructor does not need to be called inside the subclass.
Incorrect. Refer to Section 7 Lesson 4.
12It is possible to extend a class that already exists in Java, such as the Applet
. class. True or false?

Mark for

Review
(1) Points
True (*)
False
Correct
13Consider creating a class Square that extends the Rectangle class provided
. below. Knowing that a square always has the same width and length, which of
the following best represents a constructor for the Square class?

Mark for
Review
(1) Points

(*)
None of the above.
Incorrect. Refer to Section 7 Lesson 4.

You might also like