I have been engaged in the IT industry for more than 10 years. The following are some knowledge points that I often ask when I am looking for a Java development position. I hope to give some guidance to students who are looking for a job or preparing to change jobs.

1. Two ways to obtain bytecode objects by reflection and create objects

(1) The class name. Class, for example, system.class

GetClass (), for example: new Date().getClass();

(3) class.forname (” Class name “), for example: class.forname (” java.util.date “);

There are two ways to create objects:

(1) To create objects directly with bytecode, only the default constructor can be called: bytecode. NewInstance ();

(2) Get Constructor (); call Constructor ()

Anonymous inner class is a short form of inner class.

Inner class is defined in the class of the class, just like us humans, we all have a heart, and the heart has its own unique composition, can be abstracted into a class heart.

This heart class is the inner class of man. If you want to study a heart disease and you need an example, you don’t need to know whose heart it is, you find an anonymous heart.

An anonymous inner class must inherit a class or implement an interface. When used, the name of the parent class or interface creates a subclass object and implements its methods. An anonymous inner class is an anonymous subclass object.

3, what is violent reflection we know that one of the characteristics of Java is encapsulation, the object properties and concrete implementation hidden, only external public method access, private modification of the internal properties and methods are not visible to us.

We can’t get it or modify it normally, but we can get it or modify it forcibly through reflection, breaking encapsulation, and this is called violent reflection

IO system byte stream InputStream/OutputStream

| – a FileInputStream/FileOutputStream: file bytes, used in file read and write operations

| – BufferedInputStream/BufferedOutputStream: plus a byte stream buffer, used to improve the efficiency

Character stream Reader/Writer

| – FileReader/FileWriter: file character stream, for text file to read and write operations

| – BufferedReader/BufferedWrite: plus character stream buffer, used to improve the efficiency

Transformation flows InputStreamReader/OutputStreamWriter: is a byte stream and a bridge between the characters of the flow

Configuration file Properties

Reflection is the mapping of components of a Java class to the corresponding Java class.

In general, to solve a problem, we first find the relevant class, create an object of that class, and then call the corresponding method through that object to solve the problem.

Reflection is a reverse process. There may not have been a class to solve the problem, but we solved it in a way that probably didn’t exist at the time, and then there was this class.

This is actually how frameworks work, existing frameworks have classes to solve problems. The framework describes the whole, formulates the specification of the functional approach, and is written according to this specification after the concrete implementation. This is all done by reflection.

The use of the framework has good expansibility, the optimization of a part of the function does not need to involve the whole program, only need to modify the specific part, and then through the configuration file, to obtain the corresponding class name, it is ok.

6, the Collection system | – Collection

| – List: the element is orderly, element allows repeated, because the collection system have indexes

| – ArrayList: the underlying data structure is an array, the query speed, add or delete operations slower, threads are not synchronized

| – LinkedList: the underlying data structure is a linked list, query efficiency is low, add or delete operation is fast, threads are not synchronized

| – Vector: ArrayList with similar functions, the bottom is an array, difference is that the thread is synchronous, efficiency is low

| – Set: the element is unordered, elements are not allowed to repeat, the bottom with the help of the Map

| – HashSet: the underlying hash tables, stored objects autotype the equals and hashCode methods, the best guarantee element will not be repeated

| – TreeSet: the underlying binary tree, the stored object have comparative, there are two ways

| – Map: data is stored in the form of key-value pairs, some elements exist mapping relation can use the collection, elements are not allowed to repeat it

| – HashMap: allow null keys or values, the threads are not synchronized

|–TreeMap

| – HashTable: similar to a HashMap, does not allow null keys or values, thread synchronization

Member variables: They operate on the entire class and live the same life cycle as objects stored in the heap

Local variables: act on a method or statement, end the method or statement life cycle, stored in stack memory.

8, thread creation, process thread understanding

There are two options: inheriting Thread or implementing Runnable

A process is a program in execution, and each program has at least one order of execution, which is a path, or unit of control.

Thread is an independent control unit in the process, thread controls the execution of the process.

An array can store basic data types and objects. It is a linear sequence of elements that can be accessed quickly. Once an array is created, its capacity is fixed and cannot be changed during its lifetime

Collections are only used to store objects, the length of collections is variable, and collections can store different types of objects. The length of the collection is not fixed and can be easily added and deleted. It is easier to manipulate elements and more powerful

10, the difference between the synchronization function and the synchronization code block their function is to encapsulate a number of operations to share data statements, can only be executed by a thread, in the execution process, other threads can not participate in.

Synchronization code block: the location is flexible, encapsulates the operation of shared data statements, multiple threads can only hold the lock can operate shared data, need to specify an object as a lock

Synchronized method: declare methods with the synchronized keyword modifier, the synchronization function uses the lock is this, this method is called by the thread holding the lock cannot be called by other threads. Jianglogo0521: Scan qr code or manually search wechat official account