Module 4: GETTER AND SETTER Flashcards

1
Q

Are two conventional methods that are used for retrieving and updating value of a variable.

A

getter and setter

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

The naming scheme of setter and getter should follow Java bean naming convention as follows:

A

getXXX() and setXXX()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  • If the variable is of type boolean, then the getter’s name can be either isXXX() or getXXX(), but the former naming is preferred. For example:
A

private boolean single;
public String isSingle() {}

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

setter and getter method for int quantity

A

getQuantity() setQuantity(int qty)

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

setter and getter method for String firstName

A

getFirstName() setFirstname (String fname)

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

setter and getter method for boolean rich

A

isRich() getRich(), setRich(boolean rich)

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