Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
4.4k views
in Computer by (49.9k points)
closed by

The following functions numbers (int) and numbers1 (int) are a part of some class. Answer the questions given below showing the dry run/working:

public void numbers (int n) 

if (n > 0) 

System.out. print(n + " " ); numbers (n-2); 

System.out.print(n + " "); 

public String numbers1 (int n) 

if (n < = 0) return " "; 

return numbersl(n-1) + n + " "; 

}

(i) What will be the output of the function numbers (int n) when n = 5?

(ii) What will the function numbersl (int n) return when n = 6? 

(iii) State in one line what is the function numbersl (int) doing apart from recursion?

1 Answer

+1 vote
by (49.0k points)
selected by
 
Best answer

(i) 5 3 1 1 3 5 

(ii) “1 2 3 4 5 6” 

(iii) It display all number from 1 to that number.

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

...