O'Reilly logo

Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition by Rolf W. Rasmussen, Khalid A. Mughal

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

Review Questions

8.6 Given the following class, which of these static initializer blocks can be inserted after the comment?
public class MyClass {
    private static int count = 5;
    final static int STEP = 10;
    boolean alive;
    // INSERT STATIC INITIALIZER BLOCK HERE
}

Select the three correct answers.

  1. static { alive = true; count = 0; }

  2. static { STEP = count; }

  3. static { count += STEP; }

  4. static ;

  5. static {;}

  6. static { count = 1; }

8.7 What will be the result of attempting to compile and run the following code?
 public class MyClass { public static void main(String[] args) { MyClass obj = new MyClass(l); } static int i = 5; static int l; int j = 7; int k; public ...

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