Certified Java Programmer Mock Exam


Question 1

Which of the follow are true statements.

a. A nested class is any class that is declared within the body of another class or interface.
b. A nested class can not be declared within the body of an interface declaration.
c. An inner class is a nested class that is not static.
d. A nested class can not be declared static.
e. A named class is any class that is not anonymous.

Question 2

Which of the follow are true statements.

a. A local class is declared within a method, constructor or block.
b. An anonymous class is always a local class.
c. A local class is a nested class.
d. A local class is a member class.
e. A local class is always a named class.

Question 3

Which of the following are class modifiers? Select all that are applicable to a top-level class and all that are applicable to a nested class. It is not required that a modifier be applicable to both.

a. abstract
b. extends
c. final
d. implements
e. private
f. protected
g. public
h. static
i. synchronized
j. transient
k. volatile

Question 4

Which of the following modifiers can be applied to a member class?

a. abstract
b. final
c. public
d. protected
e. private
f. static
g. synchronized
h. transient

Question 5

Which of the following modifiers can be applied to a local class?

a. public
b. protected
c. private
d. abstract
e. static
f. final

Question 6

class Z {
  abstract class A {}     // 1
  final class B {}        // 2
  private class C {}      // 3
  protected class D {}    // 4
  public class E {}       // 5
}

Which class declaration results in a compile-time error?

a. 1
b. 2
c. 3
d. 4
e. 5
f. None of the above

Question 7

class Z {
  static class F {}       // 1
  synchronized class G {} // 2
  transient class H {}    // 3
  volatile class I {}     // 4
}

Which class declaration does not result in a compile-time error?

a. 1
b. 2
c. 3
d. 4
e. None of the above

Question 8

class Z {
  void m1() {
    abstract class A {}      // 1
    final class B {}         // 2
    private class C {}       // 3
    protected class D {}     // 4
    public class E {}        // 5
  }
}

Which class declarations result in compile-time errors?

a. 1
b. 2
c. 3
d. 4
e. 5

Question 9

class Z {
  void m1() {
    static class F {}        // 1
    synchronized class G {}  // 2
    transient class H {}     // 3
    volatile class I {}      // 4
    abstract class A {}      // 5
    final class B {}         // 6
  }
}

Compile-time errors are generated at which lines?

a. 1
b. 2
c. 3
d. 4
e. 5
f. 6

Question 10

class A {
  A() {}        // 1
  int A;        // 2
  void A() {}   // 3
  class A {}    // 4
}

Which line results in a compile-time error?

a. 1
b. 2
c. 3
d. 4
e. None of the above

Question 11

class A {
  int B;        // 1
  void B() {}   // 2
  class B {}    // 3
}

Which line results in a compile-time error?

a. 1
b. 2
c. 3
d. None of the above

Question 12

abstract class A {               // 1 
  private abstract void m1();    // 2
  private abstract class B {}    // 3
  private class C extends B {}   // 4
}

Which line results in a compile-time error?

a. 1
b. 2
c. 3
d. 4
e. None of the above.

Question 13

abstract class A {            // 1
  abstract final void m1();   // 2
  abstract final class B {}   // 3
  class C extends B {}        // 4
}

Which line does not result in a compile-time error?

a. 1
b. 2
c. 3
d. 4
e. None of the above

Question 14

abstract class A {                   // 1
  abstract synchronized void m1();   // 2
  abstract synchronized class B {}   // 3
  synchronized class C extends B {}  // 4
}

Which line does not result in a compile-time error?

a. 1
b. 2
c. 3
d. 4
e. None of the above


Copyright © 2002-2003, Dan Chisholm
All rights reserved.