What is the output of the following JAVA code? String s = "exam:" + 9 + 9 + 9;…
2021
What is the output of the following JAVA code? String s = "exam:" + 9 + 9 + 9; System.out.println(s);
Answer: D. exam:999 — In Java, the + operator concatenates strings from left to right. First, exam: combines with 9 to form exam:9. Then the next two 9s are appended sequentially.…
- A.
exam 27
- B.
exam:27
- C.
exam:9
- D.
exam:999
Attempted by 416 students.
Show answer & explanation
Correct answer: D
In Java, the + operator concatenates strings from left to right. First, exam: combines with 9 to form exam:9. Then the next two 9s are appended sequentially. The final result is the string exam:999.
Loading lesson…