2019 Java interview questions the basis of series 228, subject summary, you can look at how many will

Java interview questions (a)

1, object-oriented features have what?

2, access modifiers public, private, protected, and when the difference is not write (default)?

3, String is the most basic data type?

4, float f = 3.4; correct?

5, short s1 = 1; s1 = s1 + 1; wrong it short s1 = 1;? S1 + = 1; wrong?

6, Java has no goto?

7, int and Integer What is the difference?

8, & and && difference?

9, explanation of the memory stack (Stack), the use of the heap (heap) region and a method (method area) of.

10, Math.round (11.5) is equal to how much? Math.round (-11.5) equals how much?

11, switch whether acting on byte, whether acting on the long, whether acting on String?

12, calculated using the most efficient method 2 multiplied by 8?

13, the array has no length () method? String has no length () method?

14, in Java, how to jump out of the current multiple nested loops?

15, the constructor (constructor) can be rewritten if (override)?

16, two objects the same value (x.equals (y) == true), but it may have different hashCode, this sentence right?

17, can inherit String class?

18, when an object is passed as a parameter to a method, this method can change the properties of this object, and returns the result of changes in, then in the end is passed by reference or value transfer here?

19, String and StringBuilder, StringBuffer the difference?

20, the difference between overloading (Overload) and rewritable (Override) is. Overloaded method can be differentiated according to the type of return?

21, describe the principle mechanism JVM class document loading?

22, char type variable can store a Chinese characters, and why?

23, abstract class (abstract class) and interfaces (interface) What are the similarities and differences?

24, a static nested class (Static Nested Class) and inner classes (Inner Class) different?

25, Java will be a memory leak it, please describe simple.

26, abstract (abstract) whether the method can simultaneously be static (static), it also is a local method (native), which can be synchronized whether modified?

27, explained the difference between static variables and instance variables.

28, if you can make calls to non-static (non-static) method from within a static (static) method?

29, how to achieve the target clone?

30, GC is the What? Why should there be GC?

31, String s = new String ( "xyz"); created several String Object?

32, the interface is inheritable (extends) the interface? Whether abstract class can implement (implements) interfaces? Abstract class is inheritable specific class (concrete class)?

33, a ".java" whether the source file can contain multiple classes (not internal)? What are the limits?

34, Anonymous Inner Class (anonymous inner classes) can inherit other classes? Can I implement an interface?

35, the inner class can refer to its members containing class (outside of class) do? Are there any restrictions?

36, Java's final keyword in what usage?

37, pointed out that following the results of running the program

38, the data type conversion between:

39, and how to reverse the replacement string?

40, how to GB2312 encoded string into ISO-8859-1 encoded string?

41, the date and time:

42, print the current time yesterday.

43, compare the Java and JavaSciprt.

44, when to use assertions (assert)?

45, Error and Exception What is the difference?

46, try {} there is a return statement, then the code immediately after this finally try {} Lane will not be executed, when executed, return before or after?

47, how the Java language exception handling, keyword: throws, throw, try, catch, finally, respectively, how to use?

48. What is the runtime exception with a test abnormalities similarities and differences?

49, list some of your common runtime exception?

50, explained the difference between final, finally, finalize the.

51, ExampleA inheritance class Exception, class inheritance ExampleB ExampleA.

52, List, Set, Map whether inherited from the Collection interface?

53, set forth ArrayList, Vector, LinkedList storage performance and characteristics.

54, Collection and Collections of the difference?

55, List, Map, Set three interfaces while the access elements, what are the differences?

56, TreeMap and TreeSet how to compare elements in the sort? How Collections utility class in sort () method to compare elements?

57, Thread type of sleep () wait methods and objects () method can allow a thread suspended, What's the difference?

58, threads sleep () method and the yield () method What is the difference?

59, when a thread enters a synchronized method A object, other threads can access this object synchronized method B?

60, please state synchronization with the thread and the thread scheduling related methods.

61, writing multithreaded programs There are several ways to achieve?

62, synchronized keyword usage?

63, an example synchronous and asynchronous.

64, start a thread is to call the run () or start () method?

65, what is the thread pool (thread pool)?

66 relationship between the basic state of the thread and state?

67, outlining the similarities and differences between synchronized and java.util.concurrent.locks.Lock?

68, Java how to implement serialization, what is the point?

69, Java There are several types of flow?

70, write a method, enter a file name and a string, count the number of the string appear in this document.

71, how to list all the files in a directory using Java code?

72, to achieve a multi-threaded socket programming with Java echo (echo) server.

73, XML document defines several forms? What is the essential difference between them? Parsing an XML document, which has several ways?

74, you used the XML in the project which places?

75, elaborate steps JDBC database operation.

76, Statement and PreparedStatement What is the difference? Which better performance?

77, when the operation of the database using JDBC, how to improve the performance of data read? How to improve the performance of update data?

78, during the programming database connection pool What is the role?

79, what is the DAO mode?

80, ACID affairs What does it mean?

82, JDBC can handle Blob and Clob?

83, briefly regular expressions and their use.

84, Java is how to support the regular expression operations?

85, to obtain a class object class what way?

88, how to call the object's method through reflection?

90, briefly you understand the design patterns.

91, written in Java a singleton class.

92. What is the UML?

93, which is commonly used UML diagram there?

95, a binary search written in Java.

Java interview questions (b)

1, Java can create a volatile array in it?

2, volatile enables a non-atomic operation into atomic operation it?

3, volatile qualifier had any practice?

4, volatile variable to provide any type of guarantee?

5,10 thread synchronization code and two threads, which is easier to write?

6, how do you call wait () method? If using a block or cycle? why?

8. What is Busy spin? Why should we use it?

9, Java thread dump in how to obtain a document?

10, Swing thread-safe?

11, what is the thread local variables?

12, to write a piece of code to solve a wait-notify the producer - consumer problem?

13, written in Java a thread-safe singleton (Singleton)?

14, the difference in Java sleep method and wait approach?

15, what is immutable (immutable object)? Java, how to create an immutable object?

16, we can create an immutable object that contains a variable object it?

17, Java what type of data should be used to represent the price?

18, how to convert byte String?

19, Java in how to convert bytes to type long?

20, we can cast to byte int type of variable it? If the value is greater than the range of byte type, what phenomenon will occur?

21, there are two classes, B inherits A, C inherits B, we can convert C B Why? Such as C = (C) B;

22, which contains the clone class method? Is Cloneable or Object?

23, Java in the ++ operator is thread safe?

23, not thread-safe operations. It involves multiple instructions, such as read a variable value, increase, and then stored back into memory, this process may have multiple threads cross.

24, a = a + b and a + = b distinction

25, I will be able to assign a double value in the case without a cast to type long variable it?

What 26,3 == * 0.1 0.3 will be returned? true or false?

27, int and Integer which will take up more memory?

28, why in Java String is immutable (Immutable)?

31,64-bit JVM, int length is the majority?

32, the difference between Serial and Parallel GC?

33, 32-bit and 64-bit JVM, int type variable length of the majority?

34, Java and in WeakReference SoftReference difference?

35, WeakHashMap how it works?

36, JVM option -XX: + UseCompressedOops What is the role? Why should I use?

37, how to judge by JVM Java program is 32-bit or 64-bit?

38,32-bit and 64-bit JVM JVM maximum heap memory are the majority?

39. What is the difference between JRE, JDK, JVM and JIT?

40, explained Java heap space and GC?

41, you can guarantee GC execute it?

42, how to get memory Java program uses? Heap percentage to use?

43, Java heap and stack What is the difference?

44, "a == b" and "a.equals (b)" What is the difference?

45, a.hashCode () what is the use? What is the relationship with a.equals (b)?

46, differs from the final, finalize and finally in?

47, what compile-time constants in Java is? Use it What are the risks?

48, the difference (answer) between List, Set, Map and Queue

49, () the difference between the poll method and remove () method?

50, what is the difference in Java and LinkedHashMap PriorityQueue is?

51, no difference in the ArrayList and LinkedList?

52. What are two ways to achieve a sort of collection?

53, Java in how to print an array?

54, Java in the LinkedList one-way or two-way linked list linked list?

55, Java TreeMap is the use of what the tree achieved? (answer)

56, Hashtable and HashMap What is the difference between the two?

57, Java in the HashSet, inside How does it work?

58, to write a piece of code to remove elements while traversing ArrayList?

59, we can write a container class, and then use the for-each loop code?

60, ArrayList and HashMap default size of the majority?

61, there may be two unequal objects have the same hashcode?

62, two identical objects have different hash code of it?

63, we can use it in the random number hashcode () in?

64, Java in, Comparator and Comparable What is the difference?

66, in my Java program, I have three socket, how many threads I need to handle?

67, Java in how to create a ByteBuffer?

68, Java in how to read and write ByteBuffer?

69, Java uses a big-endian or little-endian?

70, endian ByteBuffer what is?

71, Java, the direct and indirect buffer buffer What is the difference?

72, what is in Java memory-mapped cache areas are?

73, socket options TCP NO DELAY What does it mean?

74, TCP protocol and UDP protocol What is the difference?

75, Java in, ByteBuffer and StringBuffer What is the difference? (answer)

76, Java, the writing multithreaded programs when you will follow what the best practices?

77, say a few best practices for using Java in the Collections

78, say at least 5:00 Best Practices in Java using threads.

79, say the best practices five IO's (answer)

80, lists the five best practices that should be followed JDBC

81, say the best practice method overloading of several Java?

82, in a multithreaded environment, SimpleDateFormat is thread safe?

83, Java How to format a date? Such as formatting in the form of ddMMyyyy?

84, Java in how time zone in the date format in?

85, Java with java.util.Date in java.sql.Date What is the difference?

86, in Java, how to calculate the difference between two dates?

87, Java, how to convert a string YYYYMMDD date?

89, how to test a static method? (answer)

90, how to use JUnit to test a method of abnormality?

91, which you have used the unit test library to test your Java program?

92, @ Before and @BeforeClass What is the difference?

93, how to check a string contains only numbers? solution

94, how to use generics in Java to write a LRU cache?

95, write a Java program to convert byte long?

96, without the use of StringBuffer, how to reverse a string?

97, Java in how to obtain the highest frequency word appears in a document?

98, how to check out the two given string to reverse order?

99, Java in, how to print out all permutations of a string?

100, in Java, how to print out the array of repeating elements?

101, Java how to convert a string to an integer?

102, How to swap the values ​​of two integer variables without the use of temporary variables?

103, what interfaces are? Why use an interface instead of using concrete classes?

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

105, in addition to a singleton, you used any design patterns in a production environment?

106, can you explain the substitution principle Leeb it?

107, under what circumstances would violate the Law of Demeter? Why this question?

108, what adapter model is? When to use?

109, what is the "dependency injection" and "inversion of control"? Why would anyone use?

110, what is abstract class? It is the interface What is the difference? Why do you want to use too abstract class?

111, constructor injection and setter dependency injection, that way better?

112, what is the difference between dependency injection and engineering model?

113, the adapter mode and Decorator What is the difference?

114, what's the difference before the adapter mode and proxy mode?

115, what is the template method pattern?

116, when the use of visitors?

117, when used in combination mode?

118, what is the difference between inheritance and composition?

119, described in Java overloading and rewrite?

120, in Java, a nested class public static class with top What is the difference?

121, a combination of OOP, aggregate and correlate what is the difference?

122, give me an example of opening and closing the principle of design patterns in line?

The difference between 123, abstract factory pattern and prototype models?

125, nested static classes What is the difference with the top class?

126, you can write a regular expression to determine whether a string is a number right?

127, Java, the abnormal and are not subject to inspection abnormalities difference?

128, Java in, throw and throws What is the difference

129, the difference in Java, Serializable with the Externalizable?

130, Java in, DOM and SAX parsers What is the difference?

131, say three new features of JDK 1.7?

132, say five new features introduced in JDK 1.8?

133, Java in, Maven and ANT What is the difference?

Guess you like

Origin www.cnblogs.com/hwtnet/p/12082791.html