catalogue

  • Java problem summary
  • 01. Specific questions

Good news

  • Summary of blog notes [March 2016 to present], including Java basic and in-depth knowledge points, Android technology blog, Python learning notes, etc., including the summary of bugs encountered in daily development, of course, I also collected a lot of interview questions in my spare time, updated, maintained and corrected for a long time, and continued to improve… Open source files are in Markdown format! At the same time, ALSO open source life blog, from 12 years, accumulated a total of N [nearly 1 million words, gradually moved to the Internet], reprint please indicate the source, thank you!
  • Link address:Github.com/yangchong21…
  • If you feel good, you can star, thank you! Of course, also welcome to put forward suggestions, everything starts from small, quantitative change causes qualitative change!

Java problem summary

  • 01.Java Basic Questions (19)
  • 02.Java Object-oriented Issues (10)
  • 03.Java Data Structure Issues (20)
  • 04.JavaIO Flow Problems (6)
  • 05. Java Multithreading Problem (19)
  • 06.Java Virtual Machine Problems (10)
  • 07.Java Class loading Problems (8)
  • 08.Java Reflection Problems (6)
  • 10.Java exception problems (9)

01. Specific questions

1.1 01.Java Basic Questions (19)

  • 1.0.0.1 Please write equal method [String class], explain the specific principle? What are the equla methods of the Object class?
  • 1.0.0.2 What is the difference between String and StringBuffer? How to implement the bottom of StringBuffer? Can the String class be inherited? Why?
  • 1.0.0.3 String a=”” and String a=new String(“”); How to create a String?
  • 1.0.0.4 Why Are Strings Immutable in Java? String design and implementation considerations? What are the benefits of String immutable?
  • What can the 1.0.0.5 static keyword modify? What are the precautions for using static? The static keyword features? What are the problems with using static?
  • 1.0.0.6 Where is static variable stored? Lifetime of static variables? When are static variables destroyed? How to understand statically referenced object recycling?
  • 1.0.0.7 access modifier public, private, protected, and don’t write what is the difference between (the default)? How do you manage access permissions underneath access modifiers?
  • 1.0.0.8 What is the difference between static variables and instance variables? What are the differences between a member variable and a local variable? What is the difference between an external class and an inner class, and what is the life cycle?
  • 1.0.0.9 How Can I Clone objects? What are the ways of cloning? What is the difference between deep clone and shallow clone? What meaning is deep clone and shallow clone say respectively?
  • 1.0.1.0 The difference between int and Integer? What is the meaning of packing and unpacking? When should we pack/unpack? How is packing and unpacking implemented?
  • 1.0.1.1 What are the public methods of Object? What does the Object class toString() return? Why does a class have to implement the Cloneable interface to be cloned?
  • 1.0.1.2 Final, Finally, Finalize what is the difference? When will finally not be executed? Why is final in the java.lang package?
  • 1.0.1.3 Why Wildcards? Upper wildcards and lower wildcards What is an unbounded wildcard? How to understand generic compiler type checking?
  • 1.0.1.4 What is generic erasure? Can you explain it through actual cases in development? How do I get the exact type of a generic?
  • 1.0.1.5 How do I Verify that int types are thread-safe? Which types are thread-safe? What is an example of thread safety [AtomicInteger]?
  • 1.0.1.6 What if some fields in Java sequence do not want to be serialized? How does the Java serialization mechanism work?
  • 1.0.1.8 Limitations of raw data types and reference types? Why reference the base data wrapper class? Do basic data types have to be stored on the stack?
  • 1.0.1.9 New Integer(123) is different from integer.valueof (123).
  • 1.0.2.0 Instanceof What does it do? What should be paid attention to in the process of use? How is the underlying principle implemented? What is your understanding?

1.2 02.Java Object-oriented Issues (11)

  • 2.0.0.1 Four features of Object-oriented programming and what do they mean? What are encapsulation, inheritance and polymorphism? Why encapsulate? Why single inheritance and not multiple inheritance?
  • 2.0.0.2 What is the difference between overloading and overwriting? What is the difference between overloading and overwriting binding mechanisms? Can a static method of a parent class be overridden by a subclass? Rewriting is dynamic binding, how to understand the mechanism?
  • 2.0.0.3 What is binding? How are static and dynamic bindings different? How does dynamic binding compilation work? How does dynamic binding work?
  • 2.0.0.4 What is the difference between interfaces and Abstract classes? What is the meaning of interfaces? What is the meaning of abstract classes? How do I choose abstract classes and interfaces?
  • 2.0.0.5 Why must external variables of inner class calls be final? How do local variables affect the garbage collection mechanism?
  • 2.0.0.7 What is polymorphism? What are the ways to implement polymorphism? What are the disadvantages of polymorphism? What are the requirements for Java to implement polymorphism? How does polymorphism work?
  • 2.0.0.9 What is the difference between static variables and member variables? What are the code blocks? Which comes first, the construct code block or the constructor?
  • 2.0.0.8 Abstract the service methods of different object classification, disintegrate the tightly coupled relationship of business logic, and realize the isolation of code to ensure convenient extension?
  • 2.0.1.0 What are the characteristics of abstract classes? What is the difference between an abstract class and an ordinary class? Can abstract classes be new? What could go wrong?
  • 2.0.1.1 What are inner classes and what are they? What is the difference between a static inner class and a non-static inner class? What are the main functions of inner class effects? Does an inner class relate to an outer class?

1.3 03.Java Data Structure Issues (20)

  • 3.0.0.1 What is the difference between system.arrayCopy () and arrays.copyof () methods in arrayList? Array.arraycopy () and array.copyof ()
  • Why SparseArray performs better than HashMap?
  • 3.0.0.3 Different implementation principles of Sort between Arrays and Collections? Tell me the difference…
  • 3.0.0.4 What classes are in the Java Collections framework? What are the features? Fail-fast, a fast failure mechanism for Java collections?
  • 3.0.0.5 What are the differences between ArrayList, Vector and LinkList? What is a load factor?
  • 3.0.0.6 How can I Understand the Capacity Expansion cost of ArrayList? Can Arrays. AsList be expanded? How to serialize an ArrayList?
  • 3.0.0.7 How to Understand the READ/write mechanism and efficiency of list collections? What is CopyOnWriteArrayList, and how is it different from ArrayList?
  • 3.0.1.0 What is the difference between HashSet and TreeSet? How do you guarantee unique values? How does the bottom layer do that?
  • 3.0.1.5 What is the difference between HashMap and Hashtable? How does a HashMap handle put and get elements? What data structures are represented?
  • 3.0.1.6 How to Ensure HashMap Thread Safety? How is it implemented at the bottom? Is a HashMap ordered? How to achieve order?
  • 3.0.1.7 What happens when HashMap stores the same Hashcode of two objects? If two keys have the same Hashcode, how do you get the value object?
  • 3.0.1.8 HashMap Why not use the hash value of hashCode() as the subscript of the table?
  • 3.0.1.9 Why wrapper classes such as String and Integer in HashMap are suitable for K? Why not use a different key?
  • 3.0.2.0 How to expand HashMap? How do I understand that the size of the HashMap exceeds the capacity defined by the load factor? Any problems with resizing the HashMap?

1.4 04.Java Io flow Problems (9)

  • 4.0.0.1 Describe the common classes in Java IO, byte stream, character stream, interface, implementation class, method blocking.
  • 4.0.0.2 What is a Bit, what is a Byte, what is a Char, what are their lengths and what are the differences?
  • 4.0.0.3 What is the difference between character stream and byte stream? How do I select a byte stream or character stream? What is a buffer and what does it do?
  • 4.0.0.4 Which modes are used in IO flow? What are the advantages of the adapter pattern and decorator pattern used in IO flows?
  • 4.0.0.5 What is your understanding of NIO? What are the main differences between NIO and IO? How do NIO and IO affect application design?
  • 4.0.0.9 How Can I Clone objects? What are the ways of cloning? What is the difference between deep clone and shallow clone? What meaning is deep clone and shallow clone say respectively?
  • 4.0.1.0 Does shallow copy create new objects? What is copied for the base type? How to implement shallow copy? Will the object address value be the same before and after shallow copy?
  • 4.0.1.1 Which stream is used to perform a large number of byte stream reads from hard disk, why? What should I pay attention to?

1.5 05.Java multithreading problems (22)

  • 5.0.0.1 What are the advantages and disadvantages of thread pools? Why does starting a large number of threads reduce performance? What can be done to reduce performance?
  • 5.0.0.3 What is the difference between the start and run methods in a thread? What are the differences between wait and sleep? What is the difference between sleep(), join(), and yield()?
  • 5.0.0.4 What is the solution to the deadlock problem caused by writing a program in Java? How can deadlocks be prevented?
  • 5.0.0.5 ThreadLocal what does this class do? Why does ThreadLocal design a key to store the current ThreadLocal object?
  • 5.0.0.6 What is Thread safety? What are the levels of thread safety? What can be done to ensure thread safety? The difference between ReentrantLock and synchronized?
  • 5.0.0.7 What are Volatile and Synchronized used for? What are the differences? Synchronize How to implement a locking mechanism at compile time?
  • 5.0.0.8 The difference between wait() and sleep()? What are the usage scenarios? How do I wake up a blocked thread? What does thread.sleep (0) do?
  • 5.0.0.9 Concepts of synchronous and asynchronous, blocking and non-blocking? What are the usage scenarios? Tell me how you understand the difference between them.
  • 5.0.1.0 What are the states of threads? Please draw a flow chart of this state. What about the execution life cycle flow of a thread? What happens to a thread if it gets a runtime exception?
  • 5.0.1.1 Synchronized What? Who do synchronized blocks of code and synchronized methods essentially lock? Why is that?
  • 5.0.1.3 What is CAS? How does CAS work? What are the problems with CAS implementing atomic operations? Can CAS guarantee atomicity for multiple shared variables?
  • 5.0.1.4 If there are N network threads and you need to do data processing after the completion of N network threads, how will you solve this problem?
  • 5.0.1.5 What is the difference between a Runnable Interface and a Callable interface? How are thread exceptions handled in Callable? How do I detect Runnable exceptions?
  • 5.0.1.6 What happens if the thread pool queue is full when the task is submitted? What is the thread scheduling algorithm?
  • 5.0.1.7 What are Optimistic locks and pessimistic locks? What are the problems with pessimistic locking? How does optimistic locking implement conflict detection and data update?
  • 5.0.1.8 Which thread calls the constructor, static block of the thread class? Which is a better choice, synchronous method or synchronous block? Is it better to synchronize as little as possible?
  • 5.0.1.9 Synchonized (this) and synchonized(object)? Is there a difference between a method Synchronize and a static method?
  • 5.0.2.0 What is volatile? What is volatile used for? When does a thread write to main memory after performing operations in working memory?
  • 5.0.2.1 How are volatile variables updated in multiple threads? Understand the happens-before relationship for volatile? Memory state after volatile reads and writes in multiple threads?
  • 5.0.2.2 How does Volatile Work? Is a volatile int safe for multiple threads to operate on? So how do i++ thread safety?
  • 5.0.2.3 What can be done in the Java memory model to ensure atomicity, visibility, and order of concurrent processes?

1.6 06.Java Virtual Machine Problems (13)

  • 6.0.0.1 What are the run-time data areas? What does a Java virtual machine stack do? What does the local method stack do?
  • 6.0.0.2 Memory Layout of objects? What are the ways in which objects are accessed and located? What are the advantages of pointer access versus handle access?
  • 6.0.0.3 What is the object creation process? Where does the variable creation process go on the virtual machine? When are variables collected?
  • 6.0.0.4 In which data regions may OutOfMemoryError occur? Please describe the scenario and reason why OOM appears in this data area.
  • 6.0.0.6 What is the difference between heap and stack in Java? Write programs that run out of heap memory and stack memory separately? And how to solve the overflow code solution?
  • 6.0.0.7 If an object reference is set to NULL, does the garbage collector immediately free the memory occupied by the object?
  • 6.0.0.8 What are the methods of Garbage collection in Java? How to implement garbage detection? What are the disadvantages of reference counting?
  • 6.0.1.1 How to Determine whether an object survives and? Which is better, reference-counting or reachability? How to understand that an object is not necessarily recycled?
  • 6.0.1.2 Difference between class.forname () and classLoader.loadClass ()? For actual development you use that. Why?
  • 6.0.1.3 How can I Access and Locate Java Objects? What are the advantages and disadvantages of these access methods? How to understand access by handle?
  • 6.0.1.4 Which chunk is memory reclamation mainly for? How do I determine if an object is dead? How to determine if a constant is discarded? How do you tell if a class is useless?

1.7 07.Java class loading problems (8)

  • 7.0.0.1 What is in the Java Memory Model? What does a program counter do? What is a constant pool for?
  • 7.0.0.2 What is a class loader? How does a class loader work? Class loader type? What is the parent delegate mechanism?
  • 7.0.0.3 When does class initialization occur? What does it do to the class after it’s initialized, loading variables, constants, and methods?
  • 7.0.0.4 Understanding the class loading order through the following code example? When class name.variable loading is encountered, do I load only the class of the variable?
  • 7.0.0.5 Look at the following code and explain the principle of constant change in the preparation and initialization phases. Variable initialization process?
  • 7.0.0.7 Say garbage collection and recycling mechanism? Why is it not feasible to reference a counter to determine whether an object is recycled? What are the reference types?
  • 7.0.0.8 How about Java class loading? What does loading do? What does validation do? What are you going to do? What does parsing do? What does initialization do?

1.8 08.Java Reflection Problems (6)

  • 8.0.0.1 What is the principle of reflection? What are the ways to get Class objects, and what does Class mean and do? What is the class class?
  • 8.0.0.2 What are some ways to improve reflection efficiency? Why does reflection cost performance? How is it affected? Give an example?
  • 8.0.0.3 What does Java reflection provide? Emission has violent access, how to prevent reflection serialization attack singleton?
  • 8.0.0.4 The actual type parameters of generics obtained by reflection? What are the methods for reflection to get constructors, variables, methods?
  • 8.0.0.5 Difference between getGenericParameterTypes and getParameterTypes?
  • 8.0.0.6 What are the functions and applications of reflection? Why does reflection cost performance compared to annotations, and what are its advantages and disadvantages?

1.10 10.Java exception mechanism issues (10)

  • 10.0.0.1 What runtime exceptions have you seen? What does the exception handling mechanism know? How to classify exceptions in terms of whether they need to be handled?
  • 10.0.0.2 Using Java Exception handling? How does exception handling work? What is the difference between checked and unchecked exceptions in Java?
  • 10.0.0.3 What good practices do you follow when handling exceptions? What is the difference between the throw and throws keywords in Java?
  • Do you know what an “exception chain” is? What exceptions have been implemented and how to write them? Can I have an empty catch block?
  • 10.0.0.5 What are the important methods of Java exception classes? What are the different scenarios that lead to “exceptions in the main thread”?
  • 10.0.0.6 What is wrong with subclass code inheriting from parent class? For IOException or Exception, can you write casually?
  • 10.0.0.7 Why do I pay attention to the exception hierarchy in a catch? What problems should be paid attention to?
  • 10.0.0.8 What are the general steps for using a custom exception class in an application? What development scenarios do you use and tell me about your programming experience?

1.12 12.Java Design Pattern Issues (3)

  • 12.0.0.1 How many ways are there to implement the singleton pattern? What is the purpose of double locking in the slacker style? What is the purpose of two short calls?
  • 12.0.0.2 How to understand the producer-consumer model? Write a code example for the producer-consumer model? What are the main ideas to solve the key problems?
  • 12.0.0.3 Look at the following code. How can we improve it by using object-oriented design principles to ensure the extensibility and decoupling of the code in the later period?

1.13 13. Other Java in-depth Questions [6]

  • 13.0.0.1 How to Analyze Java Memory Allocation using Code Cases? How does the JVM load classes? How do I assign a constructor value? Parsing method calls through objects?
  • 13.0.0.2 Will strong references be reclaimed? What are the characteristics of soft references? Soft reference Usage scenarios? How can a soft reference be reclaimed when it holds multiple objects, and what are the reclamation rules?
  • 13.0.0.3 What are the characteristics of weak references? How is weak reference collection done? What are the real development cases for weak references? When to use soft or weak references?
  • 13.0.0.4 What are the Hash application scenarios? What does a Hash table do? How to improve the search speed of hash table?
  • 13.0.0.5 What does HashCode do? Hashcode can be used directly to determine whether two objects are equal. How does HashCode improve the de-duplication logic in HashMap?
  • 13.0.0.6 What is Hashcode different from equal? When do YOU need HashCode? How do I resolve Hash conflicts? How do I get a value object when two objects have the same Hashcode?

The other is introduced

01. About blog summary links

  • 1. Tech blog round-up
  • 2. Open source project summary
  • 3. Life Blog Summary
  • 4. Himalayan audio summary
  • 5. Other summaries

02. About my blog

  • My personal website: www.yczbj.org, www.ycbjie.cn
  • Github:github.com/yangchong21…
  • Zhihu: www.zhihu.com/people/yczb…
  • Jane: www.jianshu.com/u/b7b2c6ed9…
  • csdn:my.csdn.net/m0_37700275
  • The Himalayan listening: www.ximalaya.com/zhubo/71989…
  • Source: China my.oschina.net/zbj1618/blo…
  • Soak in the days of online: www.jcodecraeer.com/member/cont.
  • Email address: [email protected]
  • Blog: ali cloud yq.aliyun.com/users/artic… 239.headeruserinfo.3.dT4bcV
  • Segmentfault headline: segmentfault.com/u/xiangjian…
  • The Denver nuggets: juejin. Cn/user / 197877…