Don't forget to create account on our site to get access to more material made only for free registered user.  

View the Exhibit.

public class Hat {

public int ID =0;

public String name = "hat";

public String size = "One Size Fit All";

public String color="";

public String getName() { return name; }

public void setName(String name) {

this.name = name;

}

}

Given

public class TestHat {

public static void main(String[] args) {

Hat blackCowboyHat = new Hat();

}

}

Which statement sets the name of the Hat instance?

A. blackCowboyHat.setName = "Cowboy Hat";

B. setName("Cowboy Hat");

C. Hat.setName("Cowboy Hat");

D. blackCowboyHat.setName("Cowboy Hat");

Answer: D

Explanation:

You have no rights to post comments

Don't forget to create account on our site to get access to more material made only for free registered user.