recategorized
2,315 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

10.1k
views
3 answers
0 votes
go_editor asked Mar 24, 2020
10,103 views
Which of the following statement(s) with regard to an abstract class in JAVA is /are TRUE ?An abstract class is one that is not used to create objectsAn abstract ... inherited by other classesOnly I only II Neither I nor IIBoth I and II
3.0k
views
3 answers
0 votes
go_editor asked Jan 31, 2017
3,012 views
Given the array of integers array' shown below:1372721833911228What is the output of the following JAVA statements?int[] p = new int [10]; int[] q = new int [10]; for ( ... [4]=20; System.out.println(array[4]+":"+q[4]);20:2018:1818:2020:18
4.2k
views
4 answers
0 votes
go_editor asked Mar 24, 2020
4,208 views
Abstraction and encapsulation are fundamental principles that underlie the object oriented approach to software development. What can you say about the following two ... correctBoth I and II are correctOnly II is correctOnly I is correct
3.9k
views
2 answers
3 votes
go_editor asked Aug 1, 2016
3,865 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 embedded in another applications