1z0-819 Exam QuestionsBrowse all questions from this exam

1z0-819 Exam - Question 40


Given the code fragment:

What is the result?

Show Answer
Correct Answer: BE

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

7 comments
Sign in to comment
ObaltOption: B
Feb 7, 2023

Correct answer is B

ObaltOption: B
Feb 7, 2023

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

KiraguJohn
Apr 24, 2023

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

RP384Option: E
Feb 8, 2023

"int =" will fail

JticOption: E
Feb 22, 2023

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) ;

StavokOption: E
Jun 6, 2023

E is correct Tested

[Removed]Option: E
Aug 30, 2023

E is correct. int = won't compile

Bugmenot240411Option: B
May 20, 2024

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