O'Reilly logo

Java 2™ Programmer Exam Cram™ 2 (Exam CX-310-035) by Marcus Green, Bill Brogden

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.  }
  • A. The method will return 258.

  • B. The method will return 102.

  • C. The method will return 259.

  • D. The method will return 103.

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required