wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes HELP ME Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "HELP ME" Watch "HELP ME" New topic
Author

HELP ME

rajani adapa
Ranch Hand

Joined: Jan 24, 2001
Posts: 54
What is the effect of adding the sixth element to a vector created in the following manner:

new Vector(5, 10);

An IndexOutOfBounds exception is raised.
The vector grows in size to a capacity of 10 elements
The vector grows in size to a capacity of 15 elements
Nothing, the vector will have grown when the fifth element was added
Select the most appropriate answer.

can anyone tell me what is the answer and why?
Peter Tran
Bartender

Joined: Jan 02, 2001
Posts: 783
Ans: The vector grows in size to a capacity of 15 elements.
For Vector, the c'tor you're invoking is:

Initial capacity = 5
capacityIncrement = 10
When you added the 6th element, the Vector had to resize. It will add 10 to the current size (5) which gives 15.
-Peter

[This message has been edited by Peter Tran (edited January 26, 2001).]
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
the answer i believe is
The vector grows in size to a capacity of 15 elements
because the inital was 5 so whenever you go over it , it will be increased to 15 i think that if you go over that , the capacity will be increased proportionaly .


Val SCJP <BR>going for SCJD
rajani adapa
Ranch Hand

Joined: Jan 24, 2001
Posts: 54
Thank u guys .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HELP ME