Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

whizlabs mock question on ArrayList

 
Mike Mitchel
Greenhorn
Posts: 12
Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mention two benefits of using ArrayList over array in software development.

(Choose two options.)
Select one or more:
A. Reduces memory footprint
B. Implements the Collection API
C. Is multi.thread safe
D. Dynamically resizes based on the number of elements in the list



My answer was B & D . But the correct answer is A & D . I am aware that A is bit ambiguous here. I saw a post in coderanch about it.But my concern is not about A , It is about B. But how on earth is B wrong?

As per the javadoc



java.util
Class ArrayList<E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<E>

All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess


Am I missing some thing here ?
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mike,

I think this kind of questions is one of the reasons why people prefer Enthuware above WhizLabs.

Do they provide an explanation of their own why B is wrong?

My opinion: If B would have been "Collection interface" there would be no discussion at all and B would be correct. If B would have been "Collection class" there would be also no discussion at all and B would be incorrect (Collection is an interface, not a class). An API usually defines a set of classes, and I guess that's why the answer is wrong.

Hope it helps!
Kind regards,
Roel
 
Tony Docherty
Bartender
Posts: 3054
59
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is A correct? It maybe correct in some situations but certainly isn't in all cases. For example if you have a given number of elements and the array is that exact size then it will have a smaller memory footprint than an ArrayList with the same number of elements.
 
Mike Mitchel
Greenhorn
Posts: 12
Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the comments. I hope I won't get ambiguous questions in the real exam.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic