Certified Java Programmer Mock Exam
Certified Java Programmer Mock Exam
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.
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.
Question 1
class MWC101 {
public static void main(String[] args) {
int[] a1 = new int[]; // 1
int a2[] = new int[5]; // 2
int[] a3 = new int[]{1,2}; // 3
int []a4 = {1,2}; // 4
int[] a5 = new int[5]{1,2,3,4,5}; // 5
}}
a. 1
b. 2
c. 3
danchisholm.net/july21/…/arrays11.html 1/3
5/7/2011 Certified Java Programmer Mock Exam
d. 4
e. 5
Question 2
class MWC102 {
public static void main (String[] args) {
byte[] a = new byte[1]; long[] b = new long[1];
float[] c = new float[1]; Object[] d = new Object[1];
System.out.print(a[0]+","+b[0]+","+c[0]+","+d[0]);
}}
a. Prints: 0,0,0,null
b. Prints: 0,0,0.0,null
c. Compile-time error
d. Run-time error
e. None of the above
Question 3
class MWC103 {
public static void main(String[] args) {
int[] a1 = {1,2,3};
int []a2 = {4,5,6};
int a3[] = {7,8,9};
System.out.print(a1[1]+","+a2[1]+","+a3[1]);
}}
a. Prints: 12
b. Prints: 15
c. Prints: 18
d. Prints: 1,4,7
e. Prints: 2,5,8
f. Prints: 3,6,9
g. Compile-time error
h. Run-time error
i. None of the above
Question 4
danchisholm.net/july21/…/arrays11.html 2/3
5/7/2011 Certified Java Programmer Mock Exam
class MWC104 {
public static void main(String[] args) {
int[5] a1; // 1
int []a2; // 2
int[ ]a3; // 3
int a4[]; // 4
}}
a. 1
b. 2
c. 3
d. 4
e. None of the above
Question 5
class MWC105 {
static boolean b1;
public static void main(String[] args) {
boolean[] array = new boolean[1];
boolean b2;
System.out.print(b1+",");
System.out.print(array[0]+",");
System.out.print(b2);
}}
a. Prints: true,true,true
b. Prints: false,false,false
c. Prints: null,null,null
d. Prints: false,true,false
e. Compile-time error
f. Run-time error
g. None of the above
danchisholm.net/july21/…/arrays11.html 3/3