Summary of Basic Questions for Java Interviews

2023/04/02 1:18

1. float f=3.4; Is it correct?

2. What is object-oriented thinking?

3. short s1 = 1; s1 = s1 + 1; Is there a mistake? short s1 = 1; s1 += 1; Is there a mistake?

4. The underlying comparison principle of=and equals

“The reference objects of two Integers are passed to a swap method to exchange references within the method. After returning, will the values of the two references find any changes?”

6. Does Java have goto?

7. What is the difference between int and Integer?

8. What is the difference between&and&&?

9. Explain the use of stacks, heaps, and static storage areas in memory.

10. What is Math. round (11.5) equal to? What is Math. round (- 11.5) equal to?

11. Can swtick act on bytes, long, and String?

Does an array have a length() method? Does String have a length() method?

13. In Java, how do I jump out of the current multiple nested loop?

14. Can constructors be overridden?

15. Two objects have the same value (x.equals (y)==true), but they can have different hash codes. Is this correct?

16. When an object is passed as a parameter to a method, the method can change the properties of the object and return the changed results. Is this value transfer or reference transfer?

17. What is the difference between String, StringBuilder, and StringBuffer?

18. The difference between overloading and overriding. What scenarios are used respectively. Can overloaded methods be distinguished by return type?

Can I store a Chinese character in a char type variable? Why?

20. What are the similarities and differences between abstract classes and interfaces? Is the interface extendable? Can abstract classes implement interfaces? Can abstract classes inherit concrete classes?

21. What is the difference between a static nested class and an inner class?

22. Is there a memory leak in Java? Please briefly describe it. When will memory leaks occur and what exceptions will be thrown by memory leaks

23. Can abstract methods be static, local, and synchronized at the same time?

24. What is the difference between static variables and instance variables?

25. Can I issue calls to non static methods from within a static method?

26. How to achieve object cloning?

27. Can a “. java” source file contain multiple classes (not internal classes)? What are the restrictions?

28. Can Anonymous Inner Class inherit from other classes? Can the interface be implemented?

Can an internal class refer to members of its containing class (external class)? Are there any restrictions?

30. What are the uses of the final keyword in Java?

31. Conversion between data types:

How do I convert a string to a basic data type?

How do I convert a basic data type to a string?

32. How to achieve string inversion and replacement?

33. When will the finalize () method be called? What is the purpose of a destructor?

34. How do I convert a GB2312 encoded string to an ISO-8859-1 encoded string?

35. If there is a return statement in try {}, will the code in finally {} immediately following this try be executed, and when will it be executed, before or after the return?

36. How does the Java language handle exceptions: How do you use throws, throws, try, catch, and finally?

37. What is the difference between final, finally, and finalize?

38. Serialization/Deserialization

39. int float short double long char Bytes occupied?

40. int range? Float range?

41. Difference between deep copy and light copy

42. When using external variables in lambda expressions, why do I need to final?

43. What is the purpose of static? (Please specify at least two types)

44. Thread safe singleton mode;

45. Write three singleton mode implementations.

46. What are the basic data types in JAVA and how many bytes each occupies.

47. The difference between ArrayList and LinkedList, and the difference between stack and queue. Difference between Queue and Deque

48. Talk about the instantiation order of classes, such as parent class static data, constructors, fields, sub class static data, and constructors

Numbers, fields, and their execution order when new.

49. What is the difference between inheritance and aggregation.

50. What are the models? Tell me about what you understand about nio, and what is the difference between nio, bio, and aio. Talk about the reactor model. Difference between NIO and BIO, what problems NIO solves, Netty threading model (source code torture)

51. How is reflection implemented in Java. Tell me about the reflection mechanism of JAVA.

52. The principle of reflection, and what are the three ways to create class instances by reflection.

53. In reflection, there is a difference between Class.forName and ClassLoader.

54. Describe several implementations of dynamic proxies, and describe their respective advantages and disadvantages.

55. The difference between dynamic proxy and cglib implementation.

56. Why can the CGlib method implement proxies for interfaces.

57. How do I automatically complete all hashcode and equals implementations for subclasses in a parent class? What are the advantages and disadvantages of doing so.

58. Please discuss the role of access modifiers public, private, protected, and default in application design based on OO design concepts.

59. The difference between error and exception, and the difference between CheckedException and RuntimeException. List some of your common runtime exceptions?

60. If you create a java.lang.String class in your own code, can this class be loaded by the classloader?

61. Relationship between hashcode and equals

62. Tell me about your understanding of the hashCode and equals methods in java. lang. Object objects. In what scenarios do you need to re implement these two methods.

63. In jdk1.5, generics have been introduced. What problems do generics exist to solve.

64. What is the use of such a.hashcode() and its relationship to a.equals (b).

65. Is it possible for two unequal objects to have the same hashcode.

66. How does HashSet work internally in Java.

67. What is serialization, how to serialize, why to serialize, what problems may be encountered with deserialization, and how to solve them.

68. Have you ever used spring’s thread pool or Java’s thread pool? Understanding Java thread pools

69. Five ways to create scheduled tasks

70. LRU cache obsolescence mechanism

71. What is the purpose of the class’s version number during class serialization? If a version number is not specified, how does the system handle it? What happens if fields are added?

72. What are the new features of JDK 1.8? Do you understand functional programming

 

Leave a Reply

Back to top