jQuery in Action, 2nd edition*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Vector and null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Vector and null" Watch "Vector and null" New topic

Vector and null

Sarma Lolla
Ranch Hand

Joined: Oct 21, 2002
Posts: 203
Which of the following types can be added to java.util.Vector?
A) reference
B) null
C) int
D) All of the above
The answer given in the mock are A, B.
When I verified I am able to add null to Vector.
Are there any other collection classes where I can add null?
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
All the Collection classes can hold nulls. By the way, the JavaRanch newsletter has a multi-part article on Collections.

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Sarma. Hashtable won't allow null for keys or values. While HashMap allows the null key and null values.

SCJP2. Please Indent your code using UBB Code
I agree. Here's the link: http://aspose.com/file-tools
subject: Vector and null
Similar Threads
Help! Class Cast Exception
Using add on Vector<?>
which object can be add into a Vector?
Splitting an XML file
Strange ClassCastException working with JTable