1. What language is Java? What is the difference between JDK, JRE and JVM

Java is a computer programming language, with cross-platform, object-oriented, generic programming characteristics, widely used in enterprise Web application development and mobile application development.

The JVM(Java Virtual Machine) is an abstract machine. It is called a virtual machine because it does not physically exist. It provides a runtime environment in which Java bytecode can be executed. It can also run programs written in other languages and compiled into Java bytecode.

The JVM is available for many hardware and software platforms. The JVM, JRE, and JDK are platform dependent because each OS is different from the other. However, Java is platform-agnostic. The JVM has three concepts: specification, implementation, and instance. The JVM performs the following primary tasks: Load code validation code Execution code provides the runtime environment

2. Three major versions of Java since 1.5

Java SE (J2SE, Java 2 Platform Standard Edition, Standard Edition) Java SE was formerly known as J2SE. It allows the development and deployment of Java applications for use in desktop, server, embedded, and real-time environments. Java SE contains classes that support Java Web services development and provide the foundation for Java EE and Java ME. Java EE (J2EE, Java 2 Platform Enterprise Edition, Enterprise Edition) Java EE was formerly known as J2EE. The Enterprise version helps develop and deploy portable, robust, scalable, and secure server-side Java applications. Java EE is built on Java SE and provides Web services, component models, management and communication apis that can be used to implement enterprise-level Service-oriented Architecture (SOA) and Web2.0 applications. In February 2018, Eclipse announced that it was officially changing the name of JavaEE to JakartaEE Java ME (J2ME, Java 2 Platform Micro Edition, Micro Edition). Java ME was formerly known as J2ME. Java ME provides a robust and flexible environment for applications running on mobile and embedded devices, such as cell phones, PDAs, TV set-top boxes, and printers. Java ME includes a flexible user interface, a robust security model, a number of built-in network protocols, and rich support for both networked and offline applications that can be downloaded dynamically. Applications based on the Java ME specification can be written once for many devices and can take advantage of the native capabilities of each device.

3. Java cross-platform and its principle

Cross-platform is a piece of code written in JAVA that can run on any operating system platform. How does JAVA do this? The JAVA source code we write is compiled into bytecode and then interpreted and executed by the JVM. As you can see, the JVM plays an important role in the cross-platform process by interpreting bytecode and executing it. Each platform has one JVM and only one copy of bytecode. A Windows JVM can interpret bytecode as instructions that can be executed on a Windows platform and execute it, while a Linux JVM can interpret bytecode as instructions that can be executed on a Linux platform and execute it. They all execute the same bytecode. This makes it cross-platform.

4. Features of the Java language

The Java language has the following characteristics: simplicity, cross-platform, object-oriented, security, multi-threading, distribution, portability, interpretation, high performance, and dynamic.

(1) simplicity the Java language is similar to C++, so programmers familiar with C++ can easily master Java, and it eliminates C++ prone to error, especially the Java language does not use Pointers, and provides automatic scrap collection, so programmers do not have to worry about memory management.

(2) Cross-platform

Cross-platform means that software can run well in any computer environment regardless of the constraints of computer hardware and operating system. In Java, its own virtual machine can well achieve cross-platform, it provides a bytecode to the underlying hardware platform and operating system barrier, making Java language cross-platform.

(3) Object oriented

Java is an object-oriented language, which makes the development of programs easier and easier to use. Such as code extension, code reuse and other functions.

(4) Security

Java security is guaranteed in two ways. On the one hand, in the Java language, C++ functions such as Pointers and free memory have been removed to avoid illegal memory operations. On the other hand, when Java is used to create a browser, the language capabilities combine with those provided by the browser itself to make it more secure. The Java language is tested many times before it can be executed on a machine. It goes through code validation, checking the format of code snippets, detecting pointer manipulation, object manipulation, and trying to change the type of an object.

(5) Multithreading

Multithreading refers to allowing two or more threads to exist in an application at the same time to support transaction concurrency and multitasking. In addition to the built-in multithreading technology, Java defines classes, methods, and so on to create and manage user-defined multithreading.

(6) Distribution

Java language supports the development of Internet applications. In the basic Java application programming interface, there is a network application programming interface, which provides libraries for network application programming, including URL, URLConnection, Socket, ServerSocket, etc. Java’s RMI(Remote method activation) mechanism is also an important means of developing distributed applications.

(7) portable

Java system itself has a strong portability, Java compiler is implemented in Java, Java running environment is implemented in ANSI C, and Java also strictly regulates the length of each basic data type

(8) Explain

Java interpreters can run object code instructions directly, and linked programs usually require fewer resources than compiled programs, so programmers can spend more time creating source programs.

(9) High performance

If the interpreter is not slow, Java can translate object code directly into machine instructions at run time, with speed comparable to C/C++ performance.

(10) Dynamic

One of the design goals of the Java language is to adapt to dynamically changing environments. Classes required by Java programs can be dynamically loaded into the runtime environment, or they can be loaded over the network. This also facilitates software upgrades.

What is bytecode and its benefits

Bytecode: A file generated by Java source code compiled by the virtual machine compiler (that is, a file extended to.class) that is not oriented to any particular processor, but only to the virtual machine. Bytecodes are extension.class files, which are compiled by a Java compiler to produce code that the JVM can understand. This code is called bytecodes, and it is not platform-oriented, it is JVM oriented.

Advantages of using bytecode: Java language solves the problem of low efficiency of traditional interpreted languages to a certain extent by means of bytecode, while retaining the characteristics of portability of interpreted languages. So Java programs run more efficiently, and because bytecode is not specific to a particular machine, Java programs can run on many different machines without recompiling.

The difference between Java and C +

7. Three Features of Java

8. Basic and reference data types in Java and their differences

9. Switch (EXPR) which data types are supported by EXPR

What is the difference between int and Integer

11 The most efficient way to compute 2^3 is

12,Math round(temb)

13, float f=34 is correct

Short s1 = 1,s1 =s1 +1 short s1 = 1; S1 plus 1. Is that wrong

15. Annotations in Java

16. Access modifiers in Java

17. The difference between overwriting and overloading

18. The difference between operators & and &

19. Java has no Goto

20, The use of this keyword

21, the use of the super keyword

22. The Java final keyword

23, Break, continue return

24. How do you get out of the current multiple nested loops in Java

25, hashCode and equals

26. What is the difference between abstract classes and interfaces

27 What is an interface

28 Differences between static and non-static variables

What is the difference between value passing and reference passing

What is reflection

31. Common methods in the String class

32, the difference between String == and equals

33. The difference between String, StringBuilder, and StringBuffer in Java

34Java differences between Final, finally and Nalize

35. Can there be multiple inheritance in Java

36. Differences between HashMap and Hashtable

37. What are the implementation classes of Map set and what are their characteristics

38 Resolve the hashMap thread insecurity problem

39. The underlying implementation principle of Hashmap

40. How to generate hash collision and how to solve it

41. Why does HashMap need to be expanded

42. How do I traverse the Mao set

43. Arraylist differs from LinkedList

How can I use List collections to ensure thread-safety

46, the difference between 10 and NIO

47. There are three approaches to multithreaded code in Java

What is the difference between the starto and run0 methods in Thread

49. What is the difference between notify and notityAll in Java

What is the difference between calling wait and sleep0 in Java

51. What is thread safety

52. What is a volatile variable in Java

53. Thread status

There are three ways to achieve thread synchronization

55. There are several ways to lock in Java

56, several implementation classes of Lock

57. Several ways to realize communication between threads

58. Differences and application scenarios between synchronized and Lock

59. Why use thread pools

60, How to create a thread pool

61. Exception architecture in Java

62. The difference between throw and throws

63 Name five common exceptions

Java 1O and NIO interview questions

66 In my Java program, I have three sockets. How many threads do I need to process them?

67, How to create a ByteBuffer in Java?

68, How to read and write ByteBuffer in Java?

69. Is Java big-endian or small-endian?

70. What is the byte order in ByteBuffer?

71. What is the difference between direct buffers and indirect buffers in Java?

72. What is a memory-mapped cache in Java?

73, what is the sodket option TCP NO DELAY?

What is the difference between TCP and UDP?

75. What is the difference between ByteBuffer and StringBuffer in Java? (Answer) Java best practices interview questions

76. What best practices do you follow when writing multithreaded programs in Java?

Name a few best practices for using Collections in Java

78. Name at least five best practices for using threads in Java.

79, Name 5 best practices of 10 (answer)

80. List five JDBC best practices that should be followed

81, Name some best practices for method overloading in Java. Date, Time and Calendar interview questions

Is SimpleDateFormat thread-safe in a multithreaded environment?

83. How to format a date in Java? For example, format to ddMMyyyy?

In Java, how to display time zones in formatted dates?

What is the difference between java.uti.Date and java.sql.Date?

86. In Java, how do you calculate the difference between two dates?

87, How to convert a string YYYYMMDD to a date in Java?

Unit test JUnt interview questions

89. How do I test static methods? (the answer)

90. How do I use JUnit to test a method for exceptions?

Which unit test library have you used to test your Java programs?

92. What’s the difference between @before and @beforeclass? Programming and code related interview questions

93. How do I check if a string contains only numbers? The solution

94. How to write an LRU cache using generics in Java?

Write a Java program to convert byte to long?

95. How do you invert a string without using a StringBuffer?

97. In Java, how do I get the highest frequency of words in a file?

How do I check if two given strings are in reverse order?

99. In Java, how do I print all permutations of a string?

100. In Java, how do YOU print duplicate elements in an array?

101. How do I convert a string to an integer in Java?

How do I exchange the values of two integer variables without using temporary variables?

Interview questions about OOP and design patterns

What is an interface? Why use interfaces instead of directly using concrete classes?

104. What is the difference between abstract classes and interfaces in Java?

105. Besides singletons, what other design patterns have you used in production?

106. Can you explain Richter’s substitution principle?

107) Under what circumstances is Demeter’s Law violated? Why is this a problem?

108. What is the adapter mode? When to use it?

109. What are dependency injection and inversion of control? Why do people use it?

What is an abstract class? How is it different from an interface? Why have you ever used abstract classes?

Which is better, constructor injection or setter dependency injection?

What is the difference between dependency injection and engineering patterns?

What is the difference between adapter mode and decorator mode?

What was the difference between the adapter pattern and the proxy pattern?

115. What is the template method pattern?

116. When to use visitor mode?

117. When to use composite mode?

118. What’s the difference between inheritance and composition?

119. Describe t and override in Java?

120. What is the difference between nested public static classes and top-level classes in Java?

121. What is the difference between composition, aggregation, and association in OOP?

Give me an example of a design pattern that meets the open and close principle.

123. What is the difference between abstract Factory pattern and prototype pattern?

A variety of other Java interview questions

125. What is the difference between a nested static class and a top-level class?

126. Can you write a regular expression to determine if a string is a number?

127. What is the difference between checked and unchecked exceptions in Java?

Throw throws (throws) throws (throws

129, What is the difference between Seriakzable and Externalzable?

130. What is the difference between a DOM and SAX parser in Java?

Name three new features in JDK 1.7.

132. Name five new features introduced in JDK 1.8.

133. What is the difference between Maven and ANT in Java?