What is the result?

Given the code fragment:
System.out.println (“Result:” +3+5);
System.out.println (“result:” + (3+5));
What is the result?

Given the code fragment:
System.out.println (“Result:” +3+5);
System.out.println (“result:” + (3+5));
What is the result?

A.
Result: 8
Result: 8

B.
Result: 35
Result: 8

C.
Result: 8
Result: 35

D.
Result: 35
Result: 35

Explanation:
In the first statement 3 and 5 are treated as strings and are simply concatenated.
In the first statement 3 and 5 are treated as integers and their sum is calculated.



Leave a Reply 0

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