Dan Chisholm's
Java Programmer Certification Mock Exam

Please Help Save a Tree!

The pages of this web site are not formatted to conserve paper, but my new book (ISBN: 0-9745862-0-X) is formatted to save paper, save your printer cartridge, save a loose-leaf binder, and save money. If you prefer to work my exams from printed pages, then give your printer a rest and buy my new book.

Today, you can find my book at BookSurge.com.

Are you a university student studying Java programming? Do you agree that my book would serve as a helpful workbook and companion to be used along with the Java fundamentals textbook that is currently being used in your class? If so, then please ask your professor to consider using my book in future classes.

If you have any questions or comments concerning my mock exams or my book, then please send an e-mail to me at scjpexam2000@yahoo.com.

I would also like to read your response to the following questions.


Question 1

Which of these words belong to the set of Java keywords?

a. Double
b. goto
c. min
d. extern
e. new
f. signed
g. finally
h. const
i. and
j. array
k. do

Question 2

class MCZ15 {
  public static void main (String[] args) {
    float a = 1.1e1f;  // 1
    float b = 1e-1F;   // 2
    float c = .1e1f;   // 3
    double d = .1d;    // 4
    double e = 1D;     // 5
}}

A compile-time error is generated at which line?

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

Question 3

Which of these words belong to the set of Java keywords?

a. declare
b. global
c. const
d. preserve
e. continue
f. Float
g. extends
h. select
i. break
j. dim
k. instanceOf

Question 4

class MCZ16 {
  public static void main (String[] args) {
    float a = 1;            // 1
    float b = 1L;           // 2
    float c = 1F;           // 3
    float d = 1.0;          // 4
}}

A compile-time error is generated at which line?

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

Question 5

Which of these words belong to the set of Java keywords?

a. next
b. catch
c. function
d. instanceof
e. mod
f. const
g. or
h. Boolean
i. goto
j. import
k. transient

Question 6

class MCZ17 {
  public static void main (String[] args) {
    String a = "\n";      // 1
    String b = "\r";      // 2
    String c = "\u000a";  // 3  \u000a = new line
    String d = "\u000d";  // 4  \u000d = return
}}

Compile-time errors are generated at which lines?

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

Question 7

Which of these words belong to the set of Java keywords?

a. byte
b. short
c. int
d. long
e. decimal
f. int64
g. float
h. single
i. double
j. boolean
k. char
l. unsigned
m. array
n. string

Question 8

class MCZ18 {
  public static void main (String[] args) {
    String a = "abcd";          // 1
    String b = "'\u0041'";      // 2
    String c = "\u0041";        // 3
    String d = "\uD7AF";        // 4
    System.out.print(a+b+c+d);  // 5
}}

A compile-time error is generated at which line?

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

Question 9

Which of these words belongs to the set of Java keywords?

a. clause
b. loop
c. expression
d. overrides
e. statement
f. assertion
g. validate
h. exception
i. cast
j. None of the above

Question 10

class MCZ20 {
  public static void main (String[] args) {
    // Insert code here.
}}

Which of the following lines can be inserted at the specified location without generating a compile-time error?

a. String a = 'a';
b. String b = 'abc';
c. String c = '\u0041';
d. String d = '\uabcd';
e. None of the above

Question 11

class MCZ21 {
  public static void main (String[] args) {
    // Insert code here.
}}

Which of the following lines can be inserted at the specified location without generating a compile-time error?

a. char a = a;
b. char b = abc;
c. char c = \u0041;
d. char d = \uabcd;
e. None of the above

Question 12

class MCZ24 {
  public static void main (String[] args) {
    char a = 061;      // 1
    char b = '\61';    // 2
    char c = '\061';   // 3
    char d = 0x0031;   // 4
    char e = '\u0031'; // 5
    System.out.print(""+a+b+c+d+e);
}}

A compile-time error is generated at which line?

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

Question 13

class MCZ25 {
  public static void main (String[] args) {
    char a = '\7';   // 1
    char b = '\61';  // 2
    char c = '\062'; // 3
    char d = '\x7';  // 4
    char e = '\x41'; // 5
    System.out.print(""+a+b+c+d+e);
}}

Compile-time errors are generated at which lines?

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

Question 14

class JJF6 {
  char c1 = 0xffff;  // 1
  char c2 = 0xfffff; // 2
  byte b1 = 0xffff;  // 3
  byte b2 = 0x7f;    // 4
  byte b3 = 0xff;    // 5
  byte b4 = -0x80;   // 6
}

Compile-time errors are generated at which lines?

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

Question 15

class MCZ19 {
  public static void main (String[] args) {
    String a1 = null;        // 1
    String b1 = 'null';      // 2
    String c1 = "null";      // 3
    String d1 = "'null'";    // 4
}}

A compile-time error is generated at which line?

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

Question 16

class MCZ22 {
  public static void main (String[] args) {
    // Insert code here.
}}

Which of the following lines will generate a compile-time error if inserted at the specified location?

a. char a = 0x0041;
b. char b = '\u0041';
c. char c = 0101;
d. char d = -1;
e. char e = (char)-1;
f. None of the above

Question 17

class MCZ23 {
  public static void main (String[] args) {
    // Insert code here.
}}

Which of the following lines can be inserted at the specified location without generating a compile-time error?

a. boolean b1 = true;
b. boolean b2 = TRUE;
c. boolean b3 = 'true';
d. boolean b4 = "TRUE";
e. boolean b5 = 0;
f. None of the above

Question 18

class GFM17 {
  int x;                                    // 1
  public static void main(String[] args) {  // 2
    int y = 0;                              // 3
    System.out.print(x+",");                // 4
    System.out.print(y);                    // 5
}}

What is the result of attempting to compile and run the program?

a. Prints: 0,0
b. Compile-time error at line 1.
c. Compile-time error at line 1.
d. Compile-time error at line 2.
e. Compile-time error at line 3.
f. Compile-time error at line 4.
g. Compile-time error at line 5.
h. Run-time error
i. None of the above


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