Limited access

Upgrade to access all content for this subject

Consider the following classes.

I.

public class Signal {

    public int frequency;
    public int strength;

    public Signal( int f, int s) { frequency = f; strength = s; }

    public int getFrequency() { return frequency; }

    public int getStrength() { return strength; }

    public void setFrequency(int f) { frequency = f; }

    public void setStrength(int s) { strength = s; }
}

II.

public class Monster {

    private int height;
    private int weight;

    public Monster( int h, int w) { height = h; weight = w; }

    public int getHeight() { return height; }

    public int getWeight() { return weight; }

    public void setHeight(int h) { height = h; }

    public void setWeight(int w) { weight = w; }
}

III.

public class Car {

    private String make;
    private String model;

    public Car( String mak, String mod ) { make = mak; model = mod; }

    private String getMake() { return make; }

    private String getModel() { return model; }

    private void setMake(String mak) { make = mak; }

    private void setModel(String mod) { model = mod; }
}

Which of the class(es) use the concept of encapsulation?

A

I only.

B

II only.

C

III only.

D

I and III only.

E

I, II, and III.

Select an assignment template