Which of the following options represents the output of the given code snippet?
Public static int addsub(int a, boolean isSub)
{
Return (isSub ? sub(a) : a + 1) ;
}
Public static int sub(int a) {
Return a - 1;
}
Public static void main(String[] args)
{
System.out.println("Sub 5 = " + addsub(5, true) +
", Add 6 = " + addsub(6, false) ) ;
}
A) Sub 5 = 6, Add 6 = 6
B) Sub 5 = 4, Add 6 = 7
C) sub 5 = 6, Add 6 = 6
D) Sub 5 = 4, Add 6 = 6
Correct Answer:
Verified
Q28: What is the error in the following
Q29: The Java method Math.round can be used
Q30: In an accounting application, you discover several
Q31: What is the output of the following
Q32: Suppose you need to write a method
Q34: Which of the following is true about
Q35: Which of the following is not legal
Q36: The Math.ceil method in the Java standard
Q37: What are the values of x and
Q38: What are the values of num1 and
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents