Oracle Certified Associate Java Se 8 Programmer · Free Practice Question Easy
Question 14
What will be the result of compiling and executing Test class?
- package com.udayan.oca;
- public class Test {
- public static void main(String[] args) {
- System.out.println("Output is: " + (10 != 5));
- }
- }
-
A
Output is: (10 != 5)
-
B
Output is: false
-
C
Compilation error
-
D
Output is: true
Reveal correct answer
Correct answer: D
Explanation
"Output is: " + (10 != 5) [Nothing to evaluate at left side, so let's evaluate the right side of +, 10 != 5 is true.]
= "Output is: " + true [+ operator behaves as concatenation operator]
= "Output is: true"
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
You must be logged in to post a comment.
