Consider the following class declarations.
public class Hat
{
private String size;
public Hat(String s)
{
size = s;
}
public String toString()
{
return "Size " + size + " hat";
}
}
public class BallCap extends Hat
{
private String team;
public BallCap(String mySize, String myTeam)
{
super(mySize);
team = myTeam;
}
public String toString()
{
return super.toString() + " with " + team + " logo";
}
}
A code segment located in a different class is intended to produce the following output.
Size L hat with Denver logo
Which of the following code segments will produce this output?
A. BallCap myHat = new BallCap("L", "Denver");
System.out.println(myHat);
B. BallCap myHat = new BallCap("Denver", "L");
System.out.println(myHat);
C. BallCap myHat = new BallCap("L");
myHat.team = "Denver";
System.out.println(myHat);
D. Hat myHat = new Hat("L", "Denver");
System.out.println(myHat);
E. Hat myHat = new Hat("L");
myHat.team = "Denver";
System.out.println(myHat);