Question: Given that the following method definition belongs to a class. What is displayed when the following statement is called? [1 mark] System.out.println(cheer( 4) ); String

Given that the following method definition belongs to a class. What is displayed when the following statement is called? [1 mark]

System.out.println(cheer( 4) );

String cheer(int n) { if (n == 1) return "Hurray!!"; else if( n == 2) return "Hip Yes " + cheer(n-1); else return "Hip " + cheer(n-1); }

Select the ONE correct answer.

Select one:

a. Hurray!! Hip Yes Hip Hip Hip

b. Hip Hip Hip Hip Yes Hurray!!

c. Hurray!! Hip Yes Hip Hip Yes

d. Hip Hip Hip Yes Hip Hurray!!

e. Hurray!! Hip Hip Hip Hip Yes

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!