Chapter 7 - Multiple Choice Flashcards

1
Q
  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.

A

The convention is to start with an uppercase letter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. 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.

A

Constructor must be same name as class name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. What is a constructor’s return type?

❑ void

❑ Object

❑ The class name

❑ A constructor does not have a return type.

A

A constructor does not have a return type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. Mutator methods typically take

❑ no parameter.

❑ one parameter, of the same type as the corresponding field.

A

one parameter, of the same type as the corresponding field.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. 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.

A

it can be accessed directly from inside its class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. 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.

A

Instance variables are private and methods are public .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. 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.

A

used to access and modify field variables of a class from outside the class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. Accessor methods typically take

❑ no parameter.

❑ one parameter, of the same type as the corresponding field.

A

no parameter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  1. Accessor methods typically

❑ are void methods.

❑ return the same type as the corresponding field.

A

return the same type as the corresponding field.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  1. To enable method chaining, mutator methods

❑ return a reference to this object.

❑ return the same type as the corresponding field.

A

return a reference to this object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  1. What is the keyword used for declaring a constant?

❑ static

❑ final

❑ constant

A

❑ static

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. What is the keyword used for declaring a class variable or method?

❑ static

❑ final

❑ class

A

static

How well did you know this?
1
Not at all
2
3
4
5
Perfectly