1) Which of the following is NOT a primitive type in Java



COP 3330 Exam #1

Multiple Choice Questions Form: A

2/13/07

1) Which of the following is NOT a primitive type in Java?

a) int b) double c) byte d) char e) none of the above

2) Which of the following defines the term "instance"?

a) one and only b) pertains to the object c) local variable

d) public method e) none of the above

3) Which of the following statements are true?

a) All classes in Java must have a main method.

b) All methods in a class must be public.

c) All instance variables in a class must be public.

d) A public class must be defined in a file with the same name as the class.

e) none of the above

4) What modifier indicates the user of a constant?

a) const b) final c) static d) int e) none of the above

5) What is the output of the following statement?

System.out.println("12+15 = "+12+15);

a) 12+15 = 27 b) 12+15 = 12+15 c) 12+15 = 1215

d) 27 = 27 e) none of the above

6) From which of the following can a Scanner object be used to read?

a) Keyboard b) text file c) .pdf file

d) both choices a and b e) both choices a and c

7) What is the output of the following program?

public class q7 {

public static void main(String[] args) {

int x = 3, y=8;

swap(x, y);

System.out.println("x = "+x+", y = "+y);

}

public static void swap(int a, int b) {

int temp = a;

a = b;

b = temp;

}

}

a) a = 3, b = 8 b) a = 8, b = 3 c) x = 3, y = 8

d) x = 8, y = 3 e) none of the above

8) What is the output of the following segment of code?

String one = new String("one");

String two = "two";

two = one + one;

System.out.println(one+two);

a) three b) onetwo c) oneoneone d) oneoneoneone e) none of the above

9) Which of the following properly opens a text file "input.txt" from which to read?

a) Scanner fin = new Scanner("input.txt");

b) File fin = new File("input.txt");

c) Scanner fin = new File("input.txt");

d) Scanner fin = new Scanner(new File("input.txt"));

e) none of the above

10) What is the output of the following segment of code?

for (int i=0; i ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download