recategorized
1,944 views
0 votes
0 votes

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. $59$        
  2. $95$       
  3. $69$      
  4. $99$
recategorized

6 Answers

3 votes
3 votes

Answer : 95

2 votes
2 votes
Option 2

 

CBSE(60) ->

                 60<100 so, x=CBSE(70)

                       ...................................80

                                           ............................................90

                                                  ......................................................100    

                                                                                     100  is not < 100  SO CBSE(100) Returns 100-1=99

            cbse(90) returns 98

      cbse(80) returns 97

   cbse(70)returns 96

cbse(60) returns 95

 

therefore ans 95
Answer:

Related questions

3 votes
3 votes
2 answers
4
go_editor asked Aug 1, 2016
3,683 views
Which one of the following is correct?Java applets cannot be written in any programming languageAn applet is not a small programAn applet can be run on its ownApplets are...