Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.Consider the following method. What is the value of recur(mouse, 2)? public static String recur(String str, int n) { if(n >= str.length()) { return str;

1.Consider the following method. What is the value of recur("mouse", 2)? public static String recur(String str, int n) { if(n >= str.length()) { return str; } return str + recur(str.substring(n), n + 2); }

A)use

B)ouse

C)mouse

D)mouseuse

E)mouseousee

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

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_2

Step: 3

blur-text-image_3

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

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions