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:999In 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.…

  1. A.

    exam 27

  2. B.

    exam:27

  3. C.

    exam:9

  4. 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.

Explore the full course: Rssb Basic Computer Instructor

Loading lesson…