What is the result?

Given:

StringBuffer b = new StringBuffer(“3”);

System.out.print(5+4+b+2+1);

What is the result?

Given:

StringBuffer b = new StringBuffer(“3”);

System.out.print(5+4+b+2+1);

What is the result?

A.
54321

B.
9321

C.
5433

D.
933

E.
Output is Similar to: 9java.lang.StringBuffer@100490121.

F.
Compilation fails.

Explanation:
The code will not compile.
The print function cannot handle the mixture of integers and strings.

Exception in thread “main” java.lang.RuntimeException: Uncompilable source code – Erroneous tree type



Leave a Reply 3

Your email address will not be published. Required fields are marked *


me

me

F
The operator + is undefined for the argument type(s) int, StringBuffer

Dylan

Dylan

Yep F, StringBuffer is a bad operand type for + operator.