Java Reference
In-Depth Information
Review today's material by taking this three-question quiz.
Questions
1.
What operator do you use to call an object's constructor method and create a new
object?
a.
+
b.
new
c.
instanceof
2.
What kinds of methods apply to all objects of a class rather than an individual
object?
a.
Universal methods
b.
Instance methods
c.
Class methods
3.
If you have a program with objects named
obj1
and
obj2
, what happens when you
use the statement
obj2 = obj1
?
a.
The instance variables in
obj2
are given the same values as
obj1
.
b.
obj2
and
obj1
are considered to be the same object.
c.
Neither (a) nor (b).
Answers
1. b.
2. c.
3. b.
The
=
operator does not copy values from one object to another. Instead, it
makes both variables refer to the same object.
Certification Practice
The following question is the kind of thing you could expect to be asked on a Java pro-
gramming certification test. Answer it without looking at today's material or using the
Java compiler to test the code.