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 1

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


BKhateib

BKhateib

Answer is F the error is “The operator + is undefined for the argument type(s) int, StringBuilder