Question: What is the output from the following program segment? class A{ public void cheers() { System.out.println(cheer(4)); } String cheer(int n) { if (n == 1)
What is the output from the following program segment?
class A{
public void cheers() { 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 one:
a. Hip Hip Hip Hip Yes Hurray!!
b. Hurray!! Hip Yes Hip Hip Hip
c. Hurray!! Hip Hip Hip Hip Yes
d. Hip Hip Hip Yes Hip Hurray!!
e. Hurray!! Hip Yes Hip Hip Yes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
