Exam Prep Practice Questions
Question 1 |
What will be the result of calling the following method with an input of 2?
1. public int adder( int N ){ 2. return 0x100 + N++ ; 3. }
|
A1: | Answer A is correct. The hexadecimal constant 0x100 is 256 in decimal so adding 2 results in 258. The post increment of N will have no effect on the returned value. The method would return 102 if the literal constant were decimal, but it is not. Therefore, answer B is incorrect. Answers C and D represent incorrect arithmetic. |
Question 2 |
What happens when you attempt to compile and run the following code?
1. public class Logic { 2. static int minusOne ... |
Get Java 2™ Programmer Exam Cram™ 2 (Exam CX-310-035) now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.