Quiz Answers
Chapter 1
1. B. A class is an abstract template used to create objects that are similar to each other.
2. B. You define how the subclass is different from its superclass. The things that are similar are already defined for you because of inheritance. Answer A is technically correct, but if everything in the subclass is identical to the superclass, there’s no reason to create the subclass.
3. C. Instance methods refer to a specific object’s behavior. Class methods refer to the behavior of all objects belonging to that class.
Chapter 2
1. B. In Java, a boolean
can be only true
or false
. If you put quotation marks around the value, it is treated like a String
rather than one of the two boolean
values.
2. C. Constant names are capitalized ...
Get Sams Teach Yourself Java in 21 Days, Sixth 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.