Which, inserted at line 2, is valid and demonstrates encapsulation?

Given:
1. public class Boat{
2. // insert code here
3. public void setGas(int v){
4. gas = v;
5. }
6. }
Which, inserted at line 2, is valid and demonstrates encapsulation?

Given:
1. public class Boat{
2. // insert code here
3. public void setGas(int v){
4. gas = v;
5. }
6. }
Which, inserted at line 2, is valid and demonstrates encapsulation?

A.
protected int gas;

B.
private int gas;

C.
public int gas;

D.
struct int gas;



Leave a Reply 0

Your email address will not be published. Required fields are marked *