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
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.