wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What is the effect of adding the sixth element to a vector created in the following m 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 "What is the effect of adding the sixth element to a vector created in the following m" Watch "What is the effect of adding the sixth element to a vector created in the following m" New topic
Author

What is the effect of adding the sixth element to a vector created in the following m

pradeep singh
Ranch Hand

Joined: Oct 23, 2007
Posts: 339
What is the effect of adding the sixth element to a vector created in the following manner:

new Vector(5, 10);

A.An IndexOutOfBounds exception is raised.
B.The vector grows in size to a capacity of 10 elements
C.The vector grows in size to a capacity of 15 elements
D.Nothing, the vector will have grown when the fifth element was added
answer is given:c
How is it possible


SCJP 5.0(75%), SCWCD 5.0(88%)
Sugantha Jeevankumar
Ranch Hand

Joined: Jun 06, 2007
Posts: 92
If you look at the API for the constructors for Vector, the 2-arg int constructors have a form of

Vector(int initialCapacity, int capacityIncrement)
Constructs an empty vector with the specified initial capacity and capacity increment.

I have a question to other Ranchers...most of the methods(in API chapter) that I come across during mock exams are'nt mentioned in K&B and are sometimes really obscure...will such questions be posed in the real exam? :roll:


SCJP 5.0
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: What is the effect of adding the sixth element to a vector created in the following m
 
Similar Threads
Vectors
vector question HUNT
vector
Hunt # 49
HELP ME