Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 25-line code segment reads as follows. Line 1: public class Dog. Line 2: open brace. Line 3: public void act, open parenthesis, close parenthesis. Line 4: open brace. Line 5: System, dot, out, dot, print, open parenthesis, open double quote, run, space, close double quote, close parenthesis, semicolon. Line 6: eat, open parenthesis, close parenthesis, semicolon. Line 7: close brace. Line 8: public void eat, open parenthesis, close parenthesis. Line 9: open brace. Line 10: System, dot, out, dot, print, open parenthesis, open double quote, eat, space, close double quote, close parenthesis, semicolon. Line 11: close brace. Line 12: close brace. Line 13: public class Under Dog extends Dog. Line 14: open brace. Line 15: public void act, open parenthesis, close parenthesis. Line 16: open brace. Line 17: super, dot, act, open parenthesis, close parenthesis, semicolon. Line 18: System, dot, out, dot, print, open parenthesis, open double quote, sleep, space, close double quote, close parenthesis, semicolon. Line 19: close brace. Line 20: public void eat, open parenthesis, close parenthesis. Line 21: open brace. Line 22: super, dot, eat, open parenthesis, close parenthesis, semicolon. Line 23: System, dot, out, dot, print, open parenthesis, open double quote, bark, space, close double quote, close parenthesis, semicolon. Line 24: close brace. Line 25: 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions

Question

Find in radians for 0 Answered: 1 week ago

Answered: 1 week ago