• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Vector and null

 
Sarma Lolla
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the Collection classes can hold nulls. By the way, the JavaRanch newsletter has a multi-part article on Collections.
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sarma. Hashtable won't allow null for keys or values. While HashMap allows the null key and null values.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic