This chapter is from the book
Quiz
Review today’s material by taking this three-question quiz.
Questions
What operator do you use to call an object’s constructor and create a new object?
- +
- new
- instanceof
What kind of methods apply to all objects of a class rather than an individual object?
- Universal methods
- Instance methods
- Class methods
If you have a program with objects named obj1 and obj2, what happens when you use the statement obj2 = obj1?
- The instance variables in obj2 are given the same values as obj1.
- obj2 and obj1 are considered to be the same object.
- Neither A nor B.
Answers
- B. The new operator is followed by a call to the object’s constructor.
- C. Class methods can be called without creating an object of that class.
- B. The = operator does not copy values from one object to another. Instead, it makes both variables refer to the same object.