Solved

Consider the Following Method

Question 96

Essay

Consider the following method:
// Assume that n >= 0
public static String decimalToBinary( int n )
{
System.out.println( "n = " + n );
if ( n == 0 || n == 1 )
return n + "";
else
return decimalToBinary( n / 2 ) + n % 2;
}
What is the output of the following code?
decimalToBinary( 1 ); // the output, NOT the return value
What is the output of the following code?
decimalToBinary( 6 ); // the output, NOT the return value
What is the output of the following code?
decimalToBinary( 37 ); // the output, NOT the return value

Correct Answer:

verifed

Verified

// decimalToBinary( 1 );
n = 1...

View Answer

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