S
S
sphinks2012-12-06 23:20:39
Java
sphinks, 2012-12-06 23:20:39

What Java Collection questions do you ask (or have you been asked) in an interview?

After several interesting interviews, I scored a list of "permanent" collection questions. I want to ask what else from the common questions I missed? Here's my list (author's questions left, so please don't write an incorrect question :-):

Hierarchy of collections.
How is ArrayList different from LinkedList?
What do you usually use (ArrayList or LinkedList)? Why?
Which is faster ArrayList or LinkedList?
How are elements removed from an ArrayList? How does the size of the ArrayList change in this case?
Suggest an efficient algorithm for removing multiple elements from the middle of a list implemented by ArrayList.
Add 1 million element, what structure are you using?

How is HashMap organized?
What is the initial number of baskets in the HashMap?
What is the estimated time complexity of fetching an element from a HashMap?
Does HashMap guarantee the specified element fetch complexity?
Role of equals and hashCode in HashMap?
Maximum number of hashCode() values?
How and when does the number of baskets increase in HashMap?

What is set?
TreeSet and HashSet? Differences?
TreeSet device?
What happens if you add elements to the TreeSet in ascending order?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
B
barker, 2012-12-07
@barker

Some well, too simple and expected questions for a serious interview.
ps what is the point of this post?

L
LeoCcoder, 2012-12-07
@LeoCcoder

on collections, they also like to ask about Concurrent Collections and their device, or about how you would modify an ArrayList for multithreaded use ... otherwise,
they usually ask something simple, for example, why an element can be lost in a HashMap, how to implement a hash function, why you can’t put byte[] in a hash collection, what is the contract of equals, or what is the complexity of iterating over all elements for ArrayList and LinkedList ... I really work with android, so apparently we are not much tormented by Java, they ask more about android)

B
barker, 2012-12-07
@barker

TheHorse, these are the basics of not even Java, but the theory of structures and algorithms. If there is no completely cunning background in the questions, I really don’t even know what else to answer here))
1. to insert, I would think, there are nuances here. But I know how both work in theory and in the implementation of the Java standard library, so I would come up with) as a commentator above, I would also lean towards ArrayList in this case
2. in algorithm complexity theory, yes, it guarantees, of course, assuming the worst
3. I didn’t quite understand, in fact the insertion order is not important, or we are talking about sampling

A
aliaksandrbudnikau, 2014-08-30
@aliaksandrbudnikau

Hello, I filmed the roles here and I'm going to shoot more on the topic. Maybe someone will be useful.
https://www.youtube.com/watch?v=IyPaSUFrhaM

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question