Certified Java Programmer Mock Exam


Question 1

class GFC100 {
  public static void main(String[] args) {
    final short s1 = 1; // 1
    final char c1 = 1;  // 2
    byte b1 = s1;       // 3
    byte b2 = c1;       // 4
    byte b3 = 1;        // 5
    byte b4 = 1L;       // 6
    byte b5 = 1.0;      // 7
    byte b6 = 1.0d;     // 8
}}

Compile-time errors are generated at which lines?

a. 1
b. 2
c. 3
d. 4
e. 5
f. 6
g. 7
h. 8

Question 2

class GFC101 {
  public static void main(String[] args) {
    byte b1 = -128;    // 1
    byte b2 = 128;     // 2
    short s1 = -32769; // 3
    short s2 = 32767;  // 4
    char c1 = 0;       // 5
    char c2 = 65536;   // 6
}}

Compile-time errors are generated at which lines?

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

Question 3

class GFC102 {
  public static void main(String[] args) {
    byte b1 = -129;    // 1
    byte b2 = 127;     // 2
    short s1 = -32768; // 3
    short s2 = 32768;  // 4
    char c1 = -1;      // 5
    char c2 = 65535;   // 6
}}

Compile-time errors are generated at which lines?

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


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