Question: Consider the following two classes. A 2 5 - line code segment reads as follows. Line 1 : public class Dog. Line 2 : open
Consider the following two classes.
A line code segment reads as follows. Line : public class Dog. Line : open brace. Line : public void act, open parenthesis, close parenthesis. Line : open brace. Line : System, dot, out, dot, print, open parenthesis, open double quote, run, space, close double quote, close parenthesis, semicolon. Line : eat, open parenthesis, close parenthesis, semicolon. Line : close brace. Line : public void eat, open parenthesis, close parenthesis. Line : open brace. Line : System, dot, out, dot, print, open parenthesis, open double quote, eat, space, close double quote, close parenthesis, semicolon. Line : close brace. Line : close brace. Line : public class Under Dog extends Dog. Line : open brace. Line : public void act, open parenthesis, close parenthesis. Line : open brace. Line : super, dot, act, open parenthesis, close parenthesis, semicolon. Line : System, dot, out, dot, print, open parenthesis, open double quote, sleep, space, close double quote, close parenthesis, semicolon. Line : close brace. Line : public void eat, open parenthesis, close parenthesis. Line : open brace. Line : super, dot, eat, open parenthesis, close parenthesis, semicolon. Line : System, dot, out, dot, print, open parenthesis, open double quote, bark, space, close double quote, close parenthesis, semicolon. Line : close brace. Line : close brace.
Assume that the following declaration appears in a class other than Dog.
Dog fido new UnderDog ;
What is printed as a result of the call fido.act
Responses
run eat
run eat
run eat sleep
run eat sleep
run eat sleep bark
run eat sleep bark
run eat bark sleep
run eat bark sleep
Nothing is printed due to infinite recursion.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
