Machine-translated by Google. Questions are authored in English.
Top

Objects and Collections - General Questions Questions and Answers

1.

Match the following with respect to java.util.* class methods :

(a) Bit Set(i) Time zone getTimezone( )
(b) Calendar(ii) int hashcode( )
(c) Time zone(iii) int nextInt( )
(d) Random(iv) Void setID(String tzName)

(a) (b) (c) (d)

Exam Year(s)

UGC NET - 2012,

Answer: A

In java.util the BitSet class has the method int hashCode() (ii), Calendar has a method returning the time zone, getTimeZone() (i), TimeZone has the method void setID(String) (iv), and Random has int nextInt() (iii). So the match is (a)-(ii), (b)-(i), (c)-(iv), (d)-(iii), option (A). Option (B) gives BitSet nextInt, option (C) gives BitSet setID, and option (D) gives TimeZone nextInt and Random setID, so they are wrong.

Please log in or register to report this question.

2.

Which of these packages contain all the collection classes?

Answer: B

Correct answer: java.util

The collection framework - List, Set, Map and their implementations, along with Collections, Arrays and the iterators - lives in java.util. It must be imported explicitly, unlike java.lang, which is imported automatically and holds the core language types such as String, Object and the wrappers.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Objects and Collections - General Questions Questions and Answers || Objects and Collections - General Questions MCQ Questions and Answers || Objects and Collections - General Questions GK Questions and Answers || Objects and Collections - General Questions GK MCQ Questions || Objects and Collections - General Questions Multiple Choice Questions and Answers || Objects and Collections - General Questions GK || GK on Objects and Collections - General Questions || Java Programming Questions and Answers || Java Programming MCQ Questions and Answers || Java Programming GK Questions and Answers || GK on Java Programming