Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

whizlabs mock question on ArrayList

 
Greenhorn
Posts: 12
Eclipse IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 3323
86
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the comments. I hope I won't get ambiguous questions in the real exam.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic