Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
190 views
in Information Technology by (103k points)
closed by

Consider the following recursive Java function f that takes two long arguments and returns a float value:

public static float f (long m, long n) {

float result = (float)m / (float)n;

if(m < 0 | n < 0) return 0.of;

else result - = f(m * 2,n * 3);

return result ;

}

Which of the following real values best approximates the value of f (1, 3) ?


1. 0.2
2. 0.4
3. 0.6
4. 0.8

1 Answer

0 votes
by (106k points)
selected by
 
Best answer
Correct Answer - Option 1 : 0.2

The correct answer is option 1.

The function f(1,3) pass the values to m,n. Then the value will typecast to float and result=0.3333. Then it enters into else statement the function f is f(2,9). 

And finally it returns result as 0.20000003.
∴ Hence the correct answer is 0.2.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...