Page 1 of 9

Java Quiz Questions and Answers

Continues for 8 more pages »
Read full document

Java Quiz Questions and Answers

  • By
  • Feb. 2013
  • 1470 Words
  • 1 View
Page 1 of 9
# Question 1 of 10 10.0 Points

Among the following options, choose the four options that describe the appropriate default values for array elements of the types indicated?

1. int -> 0

2. String -> “null”

3. Dog -> null

4. char -> ‘\u0000'

5. float -> 0.0f

6.boolean -> true

A. 1, 2, 3, 4

B. 2, 4, 5, 6

C. 3, 4, 5, 6

D. 1, 3, 4, 5

Answer Key: D

[Tips:(1), (3), (4), (5) are the correct statements. (2) is wrong because the default value for a String (and any other object reference) is null, with no quotes.(6)is wrong because the default value for boolean elements is false.]

# Question 2 of 10 10.0 Points

Which option among the following lists only Java programming language keywords?

A. goto, instanceof, native, finally, default, throws

B. byte, break, assert, switch, include

C. try, virtual, throw, final, volatile, transient

D. strictfp, constant, super, implements, do

E. class, if, void, long, Int, continue

Answer Key: A

[Tips: All the words in goto, instanceof, native, finally, default, throws are among the 49 Java keywords. Although goto reserved as a keyword in Java, goto is not used and has no function. class, if, void, long, Int, continue is wrong because the keyword for the primitive int starts with a lowercase i. try, virtual, throw, final, volatile, transient is wrong because “virtual” is a keyword in C++, but not Java. strictfp, constant, super, implements, do is wrong because “constant” is not a keyword. Constants in Java are marked static and final. byte, break, assert, switch, include is wrong because “include” is a keyword in C, but not in Java.]

# Question 3 of 10 10.0 Points

Which of the following options would legally declare, construct, and initialize an array?

A. int [] myList = {“1?, “2?, “3?};

B. int myList [] = {4, 3, 7};

C. int [] myList = (5, 8, 2);

D. int myList [] [] = {4,9,7,0};

Answer Key: B

[Tips: The only legal array...

Rate this document

What do you think about the quality of this document?

Share this document

Let your classmates know about this document and more at Studymode.com