Oracle
1Z0-803 · Question #15
Given the code fragment: System.out.println ("Result:" +3+5); System.out.println ("result:" + (3+5)); What is the result?
The correct answer is B. Result: 35. 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.
Using Operators and Decision Constructs
Question
Given the code fragment:
System.out.println ("Result:" +3+5); System.out.println ("result:" + (3+5)); What is the result?
Options
- AResult: 8
- BResult: 35
- CResult: 8
- DResult: 35
How the community answered
(47 responses)- A4% (2)
- B94% (44)
- D2% (1)
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.
Topics
#string concatenation#operator precedence#arithmetic operators
Community Discussion
No community discussion yet for this question.