Chapter 7 - Multiple Choice Flashcards
- 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.
The convention is to start with an uppercase letter.
- 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.
Constructor must be same name as class name
- What is a constructor’s return type?
❑ void
❑ Object
❑ The class name
❑ A constructor does not have a return type.
A constructor does not have a return type
- Mutator methods typically take
❑ no parameter.
❑ one parameter, of the same type as the corresponding field.
one parameter, of the same type as the corresponding field.
- 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.
it can be accessed directly from inside its class
- In a typical class, what is the general recommendation for access modifiers?
❑ Instance variables are private and methods are private.
❑ Instance variables are private and methods are public.
❑ Instance variables are public and methods are private.
❑ Instance variables are public and methods are public.
Instance variables are private and methods are public .
- Accessors and mutators are
❑ instance variables of a class.
❑ used to access and modify field variables of a class from outside the class.
❑ constructor methods.
used to access and modify field variables of a class from outside the class
- Accessor methods typically take
❑ no parameter.
❑ one parameter, of the same type as the corresponding field.
no parameter
- Accessor methods typically
❑ are void methods.
❑ return the same type as the corresponding field.
return the same type as the corresponding field.
- To enable method chaining, mutator methods
❑ return a reference to this object.
❑ return the same type as the corresponding field.
return a reference to this object.
- What is the keyword used for declaring a constant?
❑ static
❑ final
❑ constant
❑ static
- What is the keyword used for declaring a class variable or method?
❑ static
❑ final
❑ class
static