Which of the following options represents the output of the given code snippet?
Public static int addsub(int a, boolean isSub)
{
If (isSub) { return sub(a) ; }
Else {return a + 1; }
}
Public static int sub(int a) {
Return a - 1;
}
Public static void main(String[] args)
{
System.out.println("Sub 5 = " + addsub(5, false) +
", Add 6 = " + addsub(6, true) ) ;
}
A) sub 5 = 6, Add 6 = 6
B) Sub 5 = 4, Add 6 = 7
C) Sub 5 = 6, Add 6 = 5
D) Sub 5 = 4, Add 6 = 6
Correct Answer:
Verified
Q73: An effective technique for understanding the subtle
Q74: A temporary method that is used to
Q75: Given the following method, what do we
Q76: In the following code snippet, what is
Q77: Given the following method, what method call
Q79: For a program that reads three letter
Q80: What is incorrect in the following code
Q81: What is the output of the following
Q82: Which of the following code snippets returns
Q83: What is the output of the following
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