Certified Java Programmer Mock Exam


Question 1

public class Basics {}      // 1
class Basics1 {}            // 2
protected class Basics2 {}  // 3
private class Basics3 {}    // 4
Class Basics4 {}            // 5

Suppose these are top-level class declarations and not nested class declarations; and suppose that all of the declarations are contained in one file named Basics.java. Compile-time errors are generated at which lines?

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

Question 2

public class Basics {}   // 1
public class Basics2 {}  // 2
public class Basics3 {}  // 3
public class Basics4 {}  // 4

Suppose these are top-level class declarations and not nested class declarations; and suppose that all of the declarations are contained in one file named Basics.java. A compile-time error is not generated at which line?

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

Question 3

Which of the following modifiers can be applied to a class that is not a nested class?

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

Question 4

Which of the follow statements is true.

a. An anonymous class can be declared abstract.
b. A local class can be declared abstract.
c. An abstract class can be instantiated.
d. An abstract class is implicitly final.
e. An abstract class must declare at least one abstract method.
f. An abstract class can not extend a concrete class.

Question 5

public class A {int i1; void m1() {}}

Which of the following statements are true?

a. class A extends Object.
b. Field i1 is implicitly public, because class A is public.
c. Method m1 is implicitly public, because class A is public.
d. The compiler will insert a default constructor implicitly.
e. The default constructor has no throws clause.
f. The default constructor of class A has package access.
g. The default constructor accepts one parameter for each field in class A.
h. The default constructor invokes the no-parameter constructor of the superclass.

Question 6

abstract class A {}   // 1
transient class G {}  // 2
private class C {}    // 3
static class E {}     // 4

Suppose these are top-level class declarations and not nested class declarations. Which of these declarations would not produce a compile-time error?

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

Question 7

protected class D {}    // 1
synchronized class F {} // 2
volatile class H {}     // 3
final class B {}        // 4

Suppose these are top-level class declarations and not nested class declarations. Which of these declarations would not produce 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.