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

3.25 What will be printed when the following program is run?
public class ParameterPass {
    public static void main(String[] args) {
        int i = 0;
        addTwo(i++);
        System.out.println(i);
    }

    static void addTwo(int i) {
        i += 2;
    }
}

Select the one correct answer.

  1. 0

  2. 1

  3. 2

  4. 3

3.26 What will be the result of attempting to compile and run the following class?
 public class Passing { public static void main(String[] args) { int a = 0; int b = 0; int[] bArr = new int[1]; bArr[0] = b; inc1(a); inc2(bArr); System.out.println("a=" + a + " b=" + b + " bArr[0]=" + bArr[0]); } public static void inc1(int x) { x++; } public static void inc2(int[] x) { x[0]++; ...

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