In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what are the answers to the common basic interview questions in Java". In the daily operation, I believe that many people have doubts about the answers to the common basic interview questions in Java. The editor has consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the questions about "what are the answers to the common basic interview questions in Java?" Next, please follow the editor to study!
What's the difference between 1.JDK and JRE?
A: JRE is a java runtime environment that includes java virtual machines and java basic class libraries. Is the software environment needed for programs written in java language to run, and is provided for users who want to run Java programs.
JDK is a java development kit, which is needed by programmers to write java programs in Java language, and is provided to programmers.
2.What is the difference between equals = and QR?
Answer: = = is to compare the address of two objects, and equals is to compare the contents of two objects.
3. If the hashCode () of two objects is the same, then equals () must also be true, right?
A: no! Just because hashCode () is the same does not mean that two objects are the same. The hashCode value is obtained from the hash table, hash is a function, the implementation of this function is an algorithm, through the hash algorithm to calculate the hash value, the hash table is composed of hash values, a total of 8 locations.
On the contrary, equals () is the same, hashCode () must be the same. This is correct!
What is the role of 4.final in java?
A: the role of final varies depending on the type of modification:
1) final modifies attributes or variables in a class: the role of final, regardless of whether the attribute is a primitive type or a reference type.
2) the "value" stored in the variable modified by final cannot be changed. 3) final decorates the methods in the class: can be inherited, but cannot be overridden after inheritance. 4) final decorated classes: classes cannot be inherited.
How much is Math.round (- 1.5) in 5.java?
Answer:-1
Calculation method:
1) the first place 5 after the decimal point of the parameter, the result is that the absolute value of the integer part of the parameter is + 1, and the symbol (that is, positive or negative) remains unchanged.
3) the first digit after the decimal point of the parameter is 5, the result of positive number operation is integer part + 1, and the result of negative number operation is integer part.
Summary: add all more than five, equal to five positive numbers, and do not add less than five.
Does 6.String belong to the basic data type?
A: no. String is an object that is a string of programming languages such as java.
What are the classes of operation strings in 7.java? What's the difference between them?
Answer: String, StringBuffer, StringBuilder
Difference: String is an immutable object, and a new object is generated every time you change the type of String. StringBuffer and StringBuilder can change the object.
For operational efficiency: StringBuilder > StringBuffer > String
For thread safety: StringBuffer is thread-safe and can be used for multithreading; StringBuilder is non-thread-safe for single thread
String is used for frequent string manipulation. On the contrary, StringBuffer and StringBuilder are better than String.
Is 8.String str= "I" the same as String str=new String ("I")?
A: it is different because they are not the same object.
What are the common methods of the 9.String class?
A: here are 20 common methods. Format: returns the function of the type method name.
1) related to length:
Int length () gets the number of characters in a string
2) related to the array:
Byte [] getByte () converts a string to a byte array
Char [] toCharArray () converts a string to a character array
String split (String) splits a string according to the specified content
3) related to judgment:
Boolean equals () determines whether the contents of two strings are the same
Boolean equalsIsIgnoreCase (String) ignores case comparison of whether the contents of two strings are the same
Boolean contains (String) determines whether a string contains the specified content
Boolean startsWith (String) determines whether a string begins with the specified content
Boolean endsWith (String) determines whether a string ends with the specified content
4) related to the change:
String toUpperCase () converts a string to uppercase
String toLowerCase () converts all a string to lowercase
String replace (String,String) replaces everything with the specified content
String replaceAll (String,String) replaces all of the content with the specified content and supports regularization
String repalceFirst (String,String) replaces something that appears for the first time with the specified content
String substring (int) truncates from the specified subscript to the end of the string
String substring (int,int) intercepts the element corresponding to subscript ymer1 from subscript x
String trim () removes the spaces before and after a string
At this point, the study of "what are the answers to the common basic Java interview questions" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.