Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 40

Given the code fragment:

What is the result?

    Correct Answer: B

    The code initializes two char variables 'd' and 'e' with values 100 and 'e', respectively. In the ASCII table, the value 100 corresponds to the character 'd' and 'e' corresponds to the value 101. In line 2, 'd' is converted to integer and assigned to 'x', so 'x' becomes 100. In line 3, 'e' is cast to an integer and assigned to 'y', so 'y' becomes 101. The sum of 'x' and 'y' is 201. Therefore, the output of the code will be 201.

Discussion
Bugmenot240411Option: B

Correct answer is B i did run it and it print 201

[Removed]Option: E

E is correct. int = won't compile

StavokOption: E

E is correct Tested

JticOption: E

char d = 100, e = 'e' ; // line 1 int x = d ; // line 2 int y = (int) e; // line 3 System.out.println ((char) x + (char) y) ;

RP384Option: E

"int =" will fail

ObaltOption: B

There is a minor error on line 3. Should be int y = (int)e. Then B is correct answer

KiraguJohn

That minor error on line 3 is intentional otherwise an examiner would not expect you to know the ASCII code for all characters.

ObaltOption: B

Correct answer is B