Quiz

Review today's material by taking this three-question quiz.

Questions

1:What operator is used to call an object's constructor method and create a new object?
  1. +

  2. new

  3. instanceof

2:What kind of methods apply to all objects of a class rather than an individual object?
  1. Universal methods

  2. Instance methods

  3. Class methods

3:If you have a program with objects named obj1 and obj2 , what happens when you use the statement obj2 = obj1 ?
  1. The instance variables in obj2 are given the same values as obj1.

  2. obj2 and obj1 are considered to be the same object.

  3. Neither (a) nor (b).

Answers

A1: b.
A2: c.
A3: a. The = operator does not copy values from one object to another. Instead, it makes both variables refer to the same objectc

Get Sams Teach Yourself Java 2 in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.