preface

In interviews, Dubbo is a representative example of the RPC framework that is always hot, and interviewers will ask questions from various angles based on experience, and peel the layers of the underlying principles like an onion, so it is not enough to just look at the regular interview questions, it is best to read the source code yourself. On the other hand, the program ape in the usual work and rarely contact with the source code, and their hard gnaw source is also difficult.

JavaOOP, Java collection container, Java Exceptions, concurrent programming, Java reflection, Java serialization, JVM, Redis, Spring MVC, MyBatis, MySQL database, message middleware MQ, Dubbo, Linux, ZooKeeper, distributed & data structure and algorithm and other 25 special technical points, are xiaobian in each big factory summed up the interview question, there are a lot of fans rely on this PDF to win many big factory offer, Today, I am here to summarize and share with you! 【 Finished 】

Full version of Java interview questions address: 2021 latest interview questions collection collection.

The serial number project content link
1 The middleware Java Middleware Interview Questions (Latest version 2021) Juejin. Cn/post / 694870…
2 Micro service Java Micro Service Test Questions (updated version 2021) Juejin. Cn/post / 694906…
3 Concurrent programming Java Concurrent Programming Interview Questions (Updated 2021) Juejin. Cn/post / 695053…
4 Java based Java Basics Test Questions (2021 latest edition) Juejin. Cn/post / 695062…
5 Spring Boot Spring Boot Interview Questions (Updated 2021) Juejin. Cn/post / 695137…
6 Redis Redis Interview Questions (Updated 2021) Juejin. Cn/post / 695166…
7 Spring MVC Spring MVC Interview Questions (updated 2021) Juejin. Cn/post / 695166…
8 Spring Cloud Spring Cloud Interview Questions (Updated 2021) Juejin. Cn/post / 695245…
9 MySQL optimization MySQL optimized Interview Questions (2021 update) Juejin. Cn/post / 695246…
10 JVM JVM Performance Tuning Interview Questions (Latest version 2021) Juejin. Cn/post / 695246…
11 Linux Linux Interview Questions (Latest edition, 2021) Juejin. Cn/post / 695287…
12 Mybatis Mybatis Interview Questions (latest version 2021) Juejin. Cn/post / 695287…
13 Network programming TCP, UDP, Socket, Http Network Programming Juejin. Cn/post / 695287…
14 Design patterns Design Mode Interview Questions (latest version 2021) Juejin. Cn/post / 695544…
15 Big data 100 Big Data Interview Questions (the latest version of 2021) Juejin. Cn/post / 695544…
16 Tomcat Tomcat Interview Questions (latest version 2021) Juejin. Cn/post / 695570…
17 multithreading Multi-threaded Interview Questions (Latest edition 2021) Juejin. Cn/editor/draf…
18 Nginx Nginx_BIO_NIO_AIO Interview Questions (Updated 2021) Juejin. Cn/editor/draf…
19 memcache Memcache Interview Questions (Updated 2021) Juejin. Cn/post / 695608…
20 Java exception Java Exception Interview Questions (latest edition, 2021) Juejin. Cn/post / 695644…
21 The Java virtual machine Java Virtual Machine Interview Questions (Latest version 2021) Juejin. Cn/post / 695658…
22 Java collection Java Collection Interview Questions (Latest edition 2021) Juejin. Cn/post / 695684…
23 Git Common Commands Git Common Commands (updated 2021) Juejin. Cn/post / 695692…
24 Elasticsearch Elasticsearch Interview Questions (Updated 2021) Juejin. Cn/post / 695840…
25 Dubbo Dubbo Interview Questions (Latest edition 2021) Juejin. Cn/post / 695842…

First, Java overview

What is programming

2. What is Java

3. Three versions after JDk1.5

4. Differences between Jdk and Jre and JVM

5. What is cross-platform? How does it work?

  • Cross-platform means that a program written in the Java language can be compiled once and run on multiple systems.
  • Implementation principle: Java programs are run on the system platform through the Java virtual machine. As long as the corresponding Java virtual machine can be installed on the system, the system can run Java programs.

What are the characteristics of the Java language

  • Easy to learn (The Java language syntax is very similar to C and C++)
  • Object-oriented (encapsulation, inheritance, polymorphism)
  • Platform independence (The Java virtual machine implements platform independence)
  • Supports network programming and is convenient (the Java language itself was designed to simplify network programming)
  • Support for multithreading (a mechanism that allows an application to execute multiple tasks in parallel at the same time)
  • Robustness (the Java language’s strong typing mechanism, exception handling, automatic garbage collection, etc.)
  • Good safety

7. What is bytecode? What are the biggest benefits of adopting bytecode

What is the main class of a Java program? What is the difference between the main classes of applications and applets?

9. What are the differences between Java applications and applets?

10. The difference between Java and C++

11. Comparison of Oracle JDK and OpenJDK

Second, basic grammar

The data type

12. What data types do Java have

13. Whether switch can be used on bytes, whether switch can be used on longs, whether switch can be used on strings

14. Calculate 2 times 8 in the most efficient way

  • 2 is less than or equal to 3.

15. What is the equal of Math.round(11.5)? What is math.round (-11.5)

  • Math.round(11.5) returns 12, and Math.round(-11.5) returns -11. Rounding works by adding 0.5 to the parameter and rounding it down.

16. Float f = 3.4; Whether it is right

17. short s1 = 1; s1 = s1 + 1; Didn’t you? short s1 = 1; s1 += 1; Is wrong?

coding

18. What coding scheme does the Java language use? What are the characteristics?

  • The Java language uses the Unicode coding standard, Unicode (standard code), which assigns a unique value to each character, so programs can safely use it on any language, platform, or platform.

annotation

19. What Java annotations

Access modifier

20. Access modifier public, private, protected, and don’t write the difference (default)

The operator

21. The difference between & and &&

The keyword

22. Does Java have goto

  • Goto is a reserved word in Java and is not used in the current version of Java.

23. What’s the use of final?

24. Finally Finalize

25. The use of this keyword

26. Usage of the super keyword

class Person{ protected String name; public Person(String name) { this.name = name; } } class Student extends Person{ private String name; public Student(String name, String name1) { super(name); this.name = name1; } public void getInfo(){ System.out.println(this.name); //Child System.out.println(super.name); //Father } } public class Test { public static void main(String[] args) { Student s1 = new Student("Father","Child"); s1.getInfo(); }}Copy the code

27. What’s the difference between this and super

28. Main meaning of static existence

29. What is static

30. Static application scenario

31. Static Considerations

  • 1, static only static access.
  • 2, non-static can access both non-static and static

Flow control statement

32. break,continue,return

  • Break breaks out of the previous loop and no longer executes the loop (terminates the current loop body)
  • Continue To break out of this loop and continue the next loop (to end the loop that is executing and enter the next loop condition)
  • Return, no longer execute the following code (end the current method returns directly)

33. How do I get out of the current multiple nested loops in Java

3. Object Orientation

Object-oriented Overview

34. The difference between object-oriented and process-oriented

Three features of object orientation

35. What are the aspects of object-oriented characteristics

36. What is polymorphic mechanism? How does the Java language implement polymorphism?

37. What are the Five Basic Principles of Object Orientation (optional)

38. Abstract classes versus interfaces

  • Abstract classes are used to capture generic features of subclasses. An interface is a collection of abstract methods.
  • From the design level, abstract class is the abstraction of class, is a kind of template design, interface is the abstraction of behavior, is a behavior specification.

The same

  • Neither interfaces nor abstract classes can be instantiated
  • Are on top of inheritance and are used to be implemented or inherited by other implementations
  • Contains abstract methods that must be overridden by their subclasses

The difference between

39. What are the differences between ordinary classes and abstract classes?

  • Ordinary classes cannot contain abstract methods; abstract classes can contain abstract methods.
  • Abstract classes cannot be directly instantiated; ordinary classes can be.

40. Can final be used on abstract classes?

No, an abstract class is defined so that other classes can inherit. If you define an abstract class as fiFinal, you can’t inherit it. That would conflict with each other, so fiFinal can’t decorate an abstract class

41. What keywords are used to create an object? How is an object instance different from an object reference?

Variables and Methods

42. What are the differences between member variables and local variables

Define the function of a constructor in Java that does nothing and has no arguments

44. The parent class constructor with no arguments is called before the subclass constructor is called.

Help subclasses do the initialization.

45. What does a class constructor do? Does a class execute correctly if it does not declare a constructor? Why is that?

The main function is to complete the class object initialization work. Yes. Because a class that has no declared constructor will have a default constructor that takes no arguments

46. What are the properties of constructors?

  • The name is the same as the class name;
  • There is no return value, but the constructor cannot be declared with void;
  • It is automatically executed when the object of the class is generated.

47. Difference between static variables and instance variables

48. Static variables are different from ordinary variables

49. What is the difference between static methods and instance methods?

50. Why is it illegal to call a non-static member inside a static method?

  • Since static methods can be called without an object, there is no way to call other non-static variables or access non-static variable members in a static method.

51. What is the return value of a method? What does the return value do?

The inner class

52. What is an inner class?

53. What are the classifications of inner classes

54. Advantages of inner classes

What are the application scenarios of inner classes

  1. Some multi-algorithm cases
  2. Solve some non-object – oriented statement blocks.
  3. Proper use of inner classes makes the code more flexible and extensible.
  4. When a class is no longer used by any other class except its external class.

56. When local inner classes and anonymous inner classes access local variables, why do variables have to be final?

57. Inner class related, see the program say run result

Overwriting and overloading

58. Whether constructor can be overridden (override)

Constructors cannot be inherited and therefore cannot be overridden, but they can be overridden.

59. The difference between “Overload” and “Override”. Can overloaded methods be distinguished by their return type?

  • Overloading and overwriting methods are both ways to achieve polymorphism, the difference being that the former implements compile-time polymorphism, while the latter implements run-time polymorphism.
  • Overloading: Occurs in the same class when the method name is the same and the argument list is different (different types, numbers, and order of arguments), regardless of the method return value and access modifiers, that is, the overloaded method cannot be distinguished by the return type
  • Override: occurs in the parent class, the method name, argument list must be the same, the return value must be less than or equal to the parent class, the exception must be less than or equal to the parent class, the access modifier must be greater than or equal to the parent class (Richter substitution principle); If the superclass method access modifier is private, then there is no override in the subclass.

Object equality judgment

60. What’s the difference between == and equals

61. HashCode vs. equals (important)

What is the difference between the equality of objects and the equality of references to them?

  • The equality of objects is compared to whether the contents in memory are equal and the equality of references is compared to whether the memory addresses they point to are equal.

Value passed

63. When an object is passed as a parameter to a method that changes the object’s properties and returns the result of the change, it is passed by value or by reference

64. Why is there only value passing in Java

65. What’s the difference between passing by value and passing by reference

Java packages

66. What are the commonly used packages in the JDK

  • Java.lang: This is the base class of the system;
  • Java. IO: This is all the input/output related classes, such as file operations;
  • Java. nio: a new package written to improve the performance of the IO package by improving the functionality in the IO package;
  • Java.net: Here are the network-related classes;
  • Java.util: This is a system helper class, specifically a collection class;
  • Java.sql: This is the class for database operations.

67. What is the difference between import Java and Javax

Fourth, IO streams

68. How many IO streams are there in Java?

69. What’s the difference between BIO,NIO and AIO?

70. What are the common methods for Files?

  • Files.exists () : checks whether the file path exists.
  • Files.createfile () : Creates a file.
  • Files.createdirectory () : Creates a folder.
  • Files.delete () : deletes a file or directory.
  • Files.copy () : copies Files.
  • Files.move () : Move a file.
  • Files.size () : displays the number of Files.
  • Files.read () : reads a file.
  • Files.write () : writes Files.

Five, the reflection

71. What is the reflex mechanism?

72. Pros and cons of reflex mechanisms

73. What are the application scenarios of reflection?

Three ways to get reflection in Java

6. Common apis

String related

The difference between character constants and string constants

76. What is a string constant pool?

77. Is String the most basic data type

78. What are the features of String

79. Why is String immutable?

80. Is String really immutable?

81. Can we inherit the String class

The String class is fifinal and cannot be inherited.

82. String STR =new String(” I “)

No, because the memory is allocated differently. String STR =” I “, the Java virtual machine will allocate it to the constant pool; String STR =new String(” I “) will be allocated to the heap.

83. String s = new String(” xyz “); Several string objects are created

84. How to reverse a string?

85. Is there a length() method for arrays? String has a length() method

Arrays do not have a length() method; they have a length attribute. String has a length() method. JavaScript uses the length attribute to get the length of a string, which can be confused with Java.

What are the common methods of the String class?

  • IndexOf () : returns the indexOf the specified character.
  • CharAt () : returns the character at the specified index.
  • Replace () : String replacement.
  • Trim () : removes whitespace at both ends of the string.
  • Split () : splits the string, returning an array of split strings.
  • GetBytes () : Returns an array of the byte type of the string.
  • Length () : Returns the length of the string.
  • ToLowerCase () : converts a string toLowerCase letters.
  • ToUpperCase () : converts the string toUpperCase characters.
  • Substring () : intercepts a string.
  • Equals () : string comparison.

87. What are the benefits of using a String as a key when using a HashMap?

The internal implementation of a HashMap uses the hashcode of the key to determine where the value is stored. Since strings are immutable, when a string is created, its Hashcode is cached and does not need to be evaluated again, so it is faster than other objects.

What is the difference between String and StringBuffer and StringBuilder? Why is String immutable

Wrapper class related

89. Automatic packing and unpacking

  • Boxing: Wrapping basic types with their corresponding reference types;
  • Unpacking: converts the packing type to the basic data type;

90. What is the difference between int and Integer

91. Is the Integer A = 127 the same as the Integer b = 127

【 答案 】 【 答案 】 【 答案 】

The last

Xiaobian to share the article here is the end, sorting is not easy, welcome to communicate with you, like xiaobian to share the article remember to pay attention to me like yo, thank you for your support!