What is object-oriented programming?
Process oriented: Follow the steps to solve the problem
Object-oriented: the objects that make up the problem are decomposed into objects, the object as the basic unit of the program, and the program and data are encapsulated in order to improve the reusability, flexibility and expansibility of the program.
Java three major features
封装继承多态性
Eight basic data types of Java
8 Basic data types:
byte、short、int、longfloat、doublebooleanchar
3 Types of reference data:
对象、数组、接口
Java Multithreading Implementation method
Thread —— 类,继承Runnable——接口,实现implement实现Callable接口通过FutureTask包装器来创建Thread线程使用ExecutorService、Callable、Future实现有返回结果的多线程
What is the difference between the start () and run () methods in the thread class?
- Start (): The role is to start a new thread, the new thread will execute the corresponding run () method, can not be repeated calls;
- Run (): can be called repeatedly, call Run (), run () in the current thread, do not start a new thread
Three threads T1, T2, T3, how do you ensure that they are executed sequentially?
- Join (): Waits for thread to end, can implement thread to execute sequentially
Write a thread-safe singleton model
Https://www.cnblogs.com/x_wukong/p/3962315.html
String, StringBuilder, stringbuffer three differences
- Operating speed/execution speed: StringBuilder > StringBuffer > String
- Strings are string constants (char-saved) and cannot be changed after the object is created, and the first two are string variables, which are reference types and can be changed.
- Thread Safety: StringBuilder is thread insecure and stringbuffer is thread safe.
- Many methods in StringBuffer can carry the Synchronized keyword, so the thread safety can be ensured;
- The StringBuilder method does not have the Synchronized keyword
- Multithreaded-stringbuffer single thread-stringbuilder
- Conclusion:
- String: Applies to a small number of string manipulation cases
- StringBuilder: For a single-threaded operation in a character buffer
- StringBuffer: For multi-threaded operation in a character buffer
Java Basics/Face questions