MCQs
Total Questions : 45
| Page 3 of 5 pages
Answer: Option D. -> Compile error - do is not valid identifier.
Answer: Option A. -> 8 7
Answer: Option C. -> Compilation fails with an error at line 3
Answer: Option C. -> Compilation fails with an error at line 6
Answer: Option D. -> Compilation fails with an error at line 8
Answer: Option C. -> -127
Answer: Option B. -> 5
Answer: Option A. -> 301.5656
None.
output:
$ javac area.java
$ java area
301.5656
Answer: Option C. -> 32
Operator ++ has more preference than *, thus g becomes 4 and when multiplied by 8 gives 32.
output:
$ javac increment.java
$ java increment
32
Answer: Option B. -> 39 44
Type casting a larger variable into a smaller variable results in modulo of larger variable by
range of smaller variable. b contains 300 which is larger than byte's range i:e -128 to 127
hence d contains 300 modulo 256 i:e 44.
output:
$ javac conversion.java
$ java conversion
39 44