7.18 Exercises, Problems, and Projects
7.18.1 Multiple Choice Exercises
-
1. What can you say about the name of a class?
❑ It must start with an uppercase letter.
❑ The convention is to start with an uppercase letter.
-
2. What can you say about the name of constructors?
❑ They must be the same name as the class name.
❑ They can be any name, just like other methods.
-
3. What is a constructor’s return type?
❑ void
❑ Object
❑ The class name
❑ A constructor does not have a return type.
-
4. It is legal to have more than one constructor in a given class.
❑ true
❑ false
-
5. In a class, if a field is private,
❑ it can be accessed directly from any class.
❑ it can be accessed directly only from inside its class.
Get Java Illuminated, 5th 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.