File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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:
subject: Vector and null
It's not a secret anymore!