• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic