Solved

Which of the Following Options Represents the Output of the Given

Question 78

Multiple Choice

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:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents