Question 53Asked in UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)

Consider the following JAVA program : public class First {

Consider the following JAVA program : public class First { public static int CBSE (int x) { if (x < 100) x = CBSE (x + 10) return (x – 1) } public static void main (String [ ] args) { system. out. print (First. CBSE (60)); } What does this program print ?
  1. A59
  2. B95
  3. C69
  4. D99
Show answerHide answer

Correct answer: (B) 95

Explanation

CBSE(60) → CBSE(70) → CBSE(80) → CBSE(90) → CBSE(100). CBSE(100) returns 99; then CBSE(90) returns 98, CBSE(80) returns 97, CBSE(70) returns 96 and CBSE(60) returns 95. So the program prints 95.

From UGC NET Computer Science PYQ, June 2017 (Paper II & III, Selected Questions)

This is question 53 of UGC NET Computer Science PYQ, June 2017 (Paper II & III, Selected Questions). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.