Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following declarations. public class NoiseMaker { public NoiseMaker

ID: 3643382 • Letter: C

Question

Consider the following declarations.

public class NoiseMaker
{
public NoiseMaker(String sound)
{ System.out.print(sound); }

public void makeNoise()
{ System.out.print(" boom"); }
}

public class LoudNoiseMaker
{
public LoudNoisemaker(String sound)
{ super(sound); }

public void makeNoise()
{
super.makeNoise();
super.makeNoise();
}
}

The following method is in a client class.

public void doIt()
{
NoiseMaker boomBox = new LoudNoiseMaker("ring");
boomBox.makeNoise();
}

What happens when these classes are compiled and the method doIt is executed?

A.) "ring boom" is printed.
B.) "ring boom boom" is printed.
C.) "boom ring" is printed.
D.) "boom ring boom" is printed.
E.) The code fails to compile because there are two calls to super.makeNoise() in the second makeNoise method.

Explanation / Answer

E) Fails to compile because LoudNoiseMaker does not inherit from anything