First, what is object oriented, talk about your understanding of object oriented

When it comes to object oriented, we should first compare process oriented. Object-oriented and process oriented are two different programming methods. Process oriented pays more attention to every step and order of things.

Let’s take washing clothes in a washing machine.

Process-oriented:

Object-oriented:

What are the differences and connections between JDK, JRE and JVM

JDK: Java development tool, for programmers to develop programs must have JDK, JDK includes jre.

JRE: The Java runtime environment. If the customer only wants to run programs that have already been developed, only the JRE, which contains the JVM, is required.

JVM: Java virtual machine. When we run a class, we call the JVM virtual machine to load the corresponding class into memory.

== = equals

When comparing String objects, == determines whether the addresses are the same.

When comparing String objects, equals determines whether the values are the same.

4. Briefly describe the role of final

Final decorates a class, and the class cannot be inherited.

Final decorates a method that cannot be overridden.

Final Modifies a variable whose value cannot be modified.

String Buffer, String Builder

String: String is final and its value cannot be changed. A new object is generated each time. If we change the value of a String frequently, Stirng is not recommended. String buffer: Its value can be changed, does not generate new objects, and it is thread-safe, can be used in multithreading. String Fuilder: Its value is mutable and does not generate new objects, but it is not thread safe.Copy the code

The difference between overloading and overwriting

Overloading: in the same class, the method name is the same, the parameter type is different, the number is different, the order is different. Overwrite: first, the subclass inherits the parent class, which overwrites the same method name as the parent class, and the same parameter type, the same number, the same order.Copy the code

The difference between interfaces and abstract classes

Abstract classes can have ordinary member functions, whereas interfaces can only have public abstract methods.

Member variables in an abstract class can be of various types, whereas member variables in an interface can only be of public static final type.

Abstract classes can inherit only one, and interfaces can be implemented multiple times.

Difference between a List and a Set

List: ordered, store objects in the order in which they were entered, repeatable, allow multiple Null element objects, you can use an Iterator to fetch all the elements and iterate over them one by one, or you can use get(int index) to get the elements with a specified index.

Set: an unordered, non-repeatable object that contains at most one Null element. The Iterator interface must be used to retrieve all elements and iterate through each element.

Hashcode and equals

The purpose of hashCode() is to get a hashCode, also known as a hashCode, which returns an int integer. The purpose of this hashCode is to determine the location of the object in the hash table, where the key-value is stored, so that we can get the object quickly.

The hashCode() of the same object must be the same, and the hashCode() of different objects need not be different.

When storing objects in a hash table, if the hashCode() of two objects is different, we insert them directly into the corresponding hash table. If the hashCode() of two objects is the same, we need equals to determine whether the two objects are really the same. Because we said that different objects don’t necessarily have different hashCode().

ArrayList and LinkedList

ArrayList: Dynamic array-based, continuous memory storage, suitable for subscript access, query, not suitable for insert and delete operations.

LinkedList: Based on linked lists, can be stored in scattered memory, suitable for data insertion and deletion operations, not for query.