Question
2.Consider the following method. What is the result of mystery(3)? public static int mystery(int n) { if (n < 5) { return mystery(n + 1)
2.Consider the following method. What is the result of mystery(3)? public static int mystery(int n) { if (n < 5) { return mystery(n + 1) 2; } return n 1; }
A)0
B)1
C)3
D)4
E)5
3.Consider the following method. What is the value of mystery(1)? public static void mystery(int n) { if(n > 5) { System.out.print(n + " "); } else { mystery(n + 3); } }
A)1
B)4
C)7
D)7 4 1
E)1 4 7
4. Consider the following method. What is the value of recur("COMPUTER")? public static void recur(String str) { int len = str.length(); if(len > 1) { String temp = str.substring(0, len 2); recur(temp); System.out.println(temp); } }
A)CO
B)COMPUT
C)C COM COMPU
D)CO COMP COMPUT
E)COMPUT COMP CO
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started