Page 176 - Computer science 868 Class 12
P. 176
8. Will the following code compile successfully? If yes, what will be the output of the code?
int x, y, z;
x = y = z = 2;
x += y;
y -= z;
z /= (x + y);
System.out.println(x + " " + y + " " + z);
9. Show the output of the following program:
double x = 10.5;
x /= 4 + 2.5 * 2.5;
System.out.println(x);
10. What is a bitwise operator in Java?
11. If x = 00001010, y = 00001011 then what is the value of z in decimal form if z = x & y?
12. What will be the output?
int x = 20;
int y = 10;
int z = (x > y)? x : y;
System.out.println("Greatest number: " +z);
13. Convert the following into if else statement.
int age = 25;
String str = "You are eligible to vote";
String str2 = "You are not eligible to vote";
String eligible = (age >= 18)? str : str2;
System.out.println(eligible);
D. Assertion and Reasoning Based Question.
Assertion: The lvalue can be a variable or a pointer but it should not be a constant.
Reason: The ‘lvalue’ refers to the operand on the left-hand side of the assignment operator.
(a) Both Assertion and Reason are true, and Reason is the correct explanation for Assertion.
(b) Both Assertion and Reason are true, but Reason is not the correct explanation for Assertion.
(c) Assertion is true and Reason is false.
(d) Assertion is false and Reason is true.
174174 Touchpad Computer Science-XII

