Java Quiz Solutions-1
Java Quiz Solutions-1
10) Which is the software which is used to convert byte code to MLL?
a. JVM
b. Compiler
c. Assembler
d. Interpreter
Answer: JVM
a. 5,11,16
b. 6,12,18
c. 6,12,16
d. 5,12,16
Answer: 6, 12, 16
Explanation:
a=5
b = a++ + a-- = 5 + 6 = 11 after this line executes now a value is 5 and
b value is 11.
C = a ++ + b++ = 5 + 11 = 16 after this line executes c value is 16, b
value is 12 and a value is 6
a. 1
b. 5
c. 0
d. 2
Answer: 0
Explanation:
a=5
b=6
c = a++ - b-- + ++a - --a = 5 – 6 + 7 – 6 = 0 thus c value is 0.
a. 6
b. 8
c. 5
d. 7
Answer: 7
Explanation:
i=5
i++ now i value is 6
i = ++i = ++6 = 7 thus i value is 7
a. 8
b. 9
c. 7
d. 6
Answer: 8
Explanation:
a.11,12
b.11,11
c.10,11
d.10,12
Answer: 11, 11
Explanation:
a = 10
b = ++a = ++10 = 11
b = a++ = 11++ = 11
Thus output of a and b is 11, 11.
7) What will be the output of the code given below?
a. 2,3,3
a. 1
b. 0
c. Error
d. None of the above
Answer: 1
Explanation:
P = --m * --n * n-- * m—
= --0 * --0 * -1 -- * -1—
=1
a. 6
b. 4
c. 5
d. 7
Answer: 5
Explanation:
a = a++ + ++a * --a – a --
=1+3*2–2
= 1 + 6 – 2 = 7 -2 = 5
Thus the output of above code is 5
a. Error
b. 0
c. 1
d. 2
Answer: 0
Explanation:
m++ / ++n * n-- / --m = 10 /11*11 / 10 = 0*11/10 = 0/10 = 0
m and n are declared as integers so decimal points are not
considered.
a. 12
b. 11
c. Error
d. None of the above
Answer: Error
Explanation:
a = 10
b = ++(++10) this is an unexpected type so you will get error.
a. Error
b. 12
c. 11
d. 14
Answer: Error
Explanation: You should not use numeric before operator so you
will get error
a. sum = 265
b. sum = 263
c. sum = 264
d. Error
Answer: b
Explanation:
c = a++ + ++b = 34 + 22 = 56 , now a = 35, b = 22
d = --a + --b + c-- = 34 + 21 + 56 = 111, now a = 34, b = 21, c = 55
and d = 111
e = a + +b + +c + d-- = 34 + (+21) + (+55) + 111 = 221 , now a = 34,
b= 21, c = 55, d = 110 and e = 221
f = -a + b-- + -c – d++ = -34 + 21 + (-55) – 110 =-178, now a = 34,
b= 20, c = 55, d = 111, e = 221 and f = -178
sum = 34 + 20 + 55 + 111 + 221 – 178 = 263
a. Error
b. 0,1,2,3,4
c. Infinite loop
d. None of the above
Answer: c
Explanation:
In the above the j value is not decrementing and incrementing so j
value remains 0 and here we are checking the condition whether
j< 5 which will be true always so it will enters infinite loop and
keeps printing the value 0.