Question 141

What is the output of the Java code? String s = "Java";

What is the output of the Java code? String s = "Java"; System.out.println(s.charAt(2) + s.length());
  1. A122
  2. BCompile error
  3. C118
  4. Dv4
Show answerHide answer

Correct answer: (A) 122

Explanation

charAt(2) = 'v' (118); char + int is int: 118 + 4 = 122.

From DSSSB TGT Computer Science Full Mock Test 5

This is question 141 of DSSSB TGT Computer Science Full Mock Test 5. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.