Question: You have written a class called Cat and have not written a toString method. Cat c = new Cat(); System.out.println(c); What happens when the code

You have written a class called Cat and have not written a toString method.

Cat c = new Cat();

System.out.println(c);

What happens when the code above is executed?

a) The Frog constructor is called.

b) "Ribbit" is printed.

c) The toString method in Object is called.

d) Error - a class cannot be instantiated without the toString method.

e) Nothing happens.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!