Interview questions _125_to_133_java various other questions in the interview

Source: Internet
Author: User
Tags stream api

This section contains questions about XML in Java, JDBC interview questions, regular expression interview questions, Java errors and exceptions, and serialized faces .

125) What is the difference between nested static classes and top-level classes? Answer
The source file name of a public top-level class is the same as the class name, and nested static classes do not have this requirement. A nested class is inside a top-level class and needs to refer to a nested static class using the name of the top-level class, such as Hashmap.entry is a nested static class, HashMap is a top-level class, and Entry is a nested static class.

126) Can you write a regular expression to determine if a string is a number? (solution)
A numeric string that can contain only numbers, such as 0 to 9 and +,-beginning with this information, you can next follow the following regular expression to determine whether the given string is a number.

127) in Java, what is the difference between checking for exceptions and not being checked for exceptions? Answer
The check exception compiler checks during compilation. For this exception, the method forces processing or is declared through the throws clause. One of these cases is a subclass of Exception, but not a subclass of RuntimeException. Non-checked is a subclass of RuntimeException, which is not checked by the compiler during the compilation phase.

In Java, what is the difference between throw and throws? Answer

Throw is used to throw an instantiated object of the Java.lang.Throwable class, meaning that you can throw an Error or a exception through the keyword throw, such as:
throw new IllegalArgumentException ("size must be multiple of 2″")

The function of throws is as part of the method declaration and signature, and the method is thrown with the appropriate exception so that the caller can handle it. In Java, any unhandled checked exception is forced to be declared in the throws clause.

129) What is the difference between Serializable and externalizable in Java? Answer
The Serializable interface is an interface for serializing Java classes so that they can be transmitted over the network or stored on disk, which is a default serialization method embedded in the JVM, expensive, fragile, and unsafe. Externalizable allows you to control the entire serialization process, specifying a specific binary format and adding security mechanisms.

In Java, what is the difference between DOM and SAX parser? Answer
The DOM parser loads the entire XML document into memory to create a DOM model tree so that it can find nodes faster and modify the XML structure, while the SAX parser is an event-based parser that does not load the entire XML document into memory. For this reason, DOM is faster than SAX and requires more memory and is not suitable for parsing large XML files.

131) Name the three new features in JDK 1.7? Answer
Although JDK 1.7 is not as large as JDK 5 and 8, there are many new features, such as try-with-resource statements, so you don't need to shut down manually when you're using streams or resources, and Java shuts down automatically. Fork-join pool To some extent to achieve the Java version of the map-reduce. A String variable and text is allowed in the Switch. The diamond operator (<>) is used for type inference, and it is no longer necessary to declare generics on the right side of a variable declaration, so you can write stronger, more concise code that can read and write. Another notable feature is the improved exception handling, such as allowing multiple exceptions to be caught in the same catch block.

132) Name the new features introduced in 5 JDK 1.8? Answer
Java 8 is a pioneering new version in Java history, with 5 main features in JDK 8 below:
Lambda expression that allows anonymous functions to be passed like an object
Stream API, making full use of modern multicore CPUs, can write very concise code
Date and time API, finally, there is a stable, simple database of dates and times for you to use
Extension methods, there can now be static, default methods in the interface.
Repeating annotations, you can now use the same annotations multiple times on the same type.

133) What is the difference between Maven and ANT in Java? Answer
While both are build tools for creating Java applications, MAVEN does more to provide a standard Java project structure based on the concept of "Convention over configuration" and to automatically manage dependencies for applications (JAR files that are dependent on the application), MAVEN and ANT See the answer to the more different tools.

That's all the face questions, so much, isn't it? I can assure you that if you can answer all the questions in the list, you can easily deal with any core Java or Advanced Java interview. Although the Servlet, JSP, JSF, JPA,JMS,EJB, and other Java EE technologies are not covered here, there are no mainstream frameworks such as Spring mvc,struts 2.0,hibernate, nor do they contain SOAP and RESTful web Service, but this list is also useful for Java developers who are ready to apply for Java Web Development positions, because all of the Java interviews, starting with the Java Foundation and the JDK API. If you think I have any Java pop-up questions that should be in this list and I'm missing out, you can give me your free advice. My goal is to create an up-to-date, optimal list of Java interview questions from a recent interview.

Interview questions _125_to_133_java various other questions in the interview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.