Home >Java >JavaInterview questions >Java interview questions summarized from many years of development experience - (4)

Java interview questions summarized from many years of development experience - (4)

王林
王林forward
2020-08-14 16:59:392091browse

Java interview questions summarized from many years of development experience - (4)

1. The operation efficiency of the two structures of Java array and linked list

The array has high efficiency. The bottom layer of the array is a continuous memory space. According to the base address and offset The amount of the address is calculated;

The data in the linked list is found by pointing the address to the next data address;

(more interview question recommendations: java common interview questions)

2. What are the reference types in Java?

Strong reference, weak reference, soft reference, virtual reference

3. Storage performance and characteristics of ArrayList, Vector and LinkedList

ArrayList stores objects in the form of arrays because It is stored in a continuous position, making insertion and deletion troublesome, but the query efficiency is high, and the continuous array is ordered and can be searched according to the index;

(recommended related tutorials: java introductory tutorial)

LinkedList stores objects in independent spaces. Each space retains the index of the next link. The query efficiency is low, but the modification and deletion efficiency is high.

Vector uses the Synchronized method (thread safety) ), the performance is lower than ArrayList

4. Do List, Set and Map inherit from Collection interface?

List, Set is, Map is not

5. What are the characteristics of each of the three interfaces List, Map and Set when accessing elements?

(Video tutorial recommendation: java course)

List allows data to be repeated and ordered. Call get(index i) to clearly indicate which number to take.

Set does not allow repeated data and has internal sorting. It can only obtain all elements through the Iterator interface and then iterate through each element one by one.

Map stores data through key-value pairs. The key is unique and the same data will be overwritten. Use the get(Object key) method to obtain the corresponding value based on the key.

The above is the detailed content of Java interview questions summarized from many years of development experience - (4). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete