Apply Your Knowledge

Exam Questions

The following sample exam questions are from Sun.

1:What would be the result of attempting to compile and run the following piece of code?
public class Test {
 static int x;
 public static void main (String args[]) {
  System.out.println("Value is " + x);
 }
}
  1. The output Value is 0 is printed.

  2. An object of type NullPointerException is thrown.

  3. An illegal array declaration syntax compiler error occurs.

  4. A possible reference before assignment compiler error occurs.

  5. An object of type ArrayIndexOutOfBoundsException is thrown.

2:What should you use to position a Button within an application Frame so that the size of the Button is not affected by the Frame size?
  1. A FlowLayout

  2. A GridLayout

  3. The center area of a BorderLayout

  4. The ...

Get Sun Certification Training Guide (310-025, 310-027): Java™ 2 Programmer and Developer Exams 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.