Solved

Consider the Following Method

Question 39

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