ICSE Class 10 Computer Applications Question 25 of 25

Values and Data Types — Question 25

Back to all questions
25
Question

Question 25

What is the output produced by the following lines of program code?

char x, y;
x = 'y';
System.out.println(x);
y = 'z';
System.out.println(y);
x = y;
System.out.println(x);
Answer

Below is the output produced by this code:

y
z
z

Variable x is assigned a value of character y so the first println prints y. Variable y is assigned a value of character z so the second println prints z. After that variable x is assigned the value of variable y which is the character z so last println prints z.