Sie sind auf Seite 1von 3

5/7/2011 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.

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.

How did you find my web site?


Where do you live?
How much experience do you have with Java?
Do you work my exams from your computer display? If so, why?
Do you work my exams from printed pages? If so, why?
Would you prefer to work my exams from the pages of my book? If not, then why?
Have you read the sample chapter of my book? What is your opinion of it?
Can you suggest three reasons for buying or not buying the book?

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
}}

Compile-time errors are generated at which lines?

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]);
}}

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

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]);
}}

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

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 compile-time error is generated at which line?

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);
}}

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

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

Copyright © 2002-2004, Dan Chisholm


All rights reserved.

danchisholm.net/july21/…/arrays11.html 3/3

Das könnte Ihnen auch gefallen