go to previous page   go to home page   go to next page highlighting

Answer:

(a+1)*b + c


No Autoboxing

The following does not work:

BigInteger sum = new BigInteger( "0" );
sum = sum.add( 5 );

You might hope that the literal five would be automatically converted into a BigInteger. But this does not happen.

The compiler does not automatically construct a BigInteger based on context as it does with wrapper classes (autoboxing).

Here is another program with an odd expression:


import java.math.BigInteger;

class OddExpression
{

  public static void main ( String[] args )
  {
    BigInteger a = new BigInteger( "34" );
    BigInteger b = new BigInteger( "-3" );
    BigInteger c = new BigInteger( "23" );
    BigInteger d = new BigInteger( "5" );
    
    BigInteger r = a.multiply( b.add(c) ).add( d );

    System.out.println("Result: " + r);
  }
}


Result: 685

QUESTION 11:

Which of the following expressions is equivalent to the above expression for r?


go to previous page   go to home page   go to next page