Java Research and Development Post interview classification (with answer)

Source: Internet
Author: User

The topic comes from http://www.codeceo.com/article/201-java-interview-qa.html, the answer oneself search on the net, if have omission, welcome treatise. Learn together and make progress together.

I. Java Fundamentals

1. Why is the string class final?

2. HashMap The source code, the realization principle, the bottom structure.

3. Tell me about some of the Java collection classes you know: list, set, queue, map implementation class.

4. Describe the respective implementations and distinctions between ArrayList and LinkedList.

5. What is the difference between the queues in Java.

6. Reflection, the difference between Class.forName and ClassLoader.

7. Java7, Java8 new features (Baidu asked, good BT).

8. The operational efficiency of both the Java array and the linked list, in which cases (starting from the beginning, starting at the end, starting from the middle), which operations (INSERT, find, delete) are efficient.

9. The problem of Java Memory leak survey location: the use of jmap,jstack and so on.

String, StringBuilder, stringbuffer differences.

The difference between Hashtable and HashMap.

13. Exception structure, run-time exceptions and non-runtime exceptions, each of these examples.

14.String a= "abc" string b = "abc" String c = new String ("abc") string d = "AB" + "C". The result of comparing them with = =.

Common methods for the. String class.

There are several reference types for Java.

17. What are the differences between abstract classes and interfaces?

an interface (interface) can be described as a special case of an abstract class, and all methods in an interface must be abstract . The method definition in the interface defaults to the public abstract type, and the member variable type in the interface defaults to public static final. In addition, interfaces and abstract classes differ in methods:
(1) abstract classes can have a construction method, the interface cannot have a construction method.
(2) abstract classes can contain non-abstract ordinary methods, all the methods in the interface must be abstract, cannot have a non-abstract ordinary method. The interface in Java 8 can have the default method.
(3) There can be ordinary member variables in an abstract class , and there are no ordinary member variables in the interface .
(4) The access type of an abstract method in an abstract class can be public,protected and the default type.
(5) A static method can be included in an abstract class, and a static method cannot be included in an interface.
(6) Abstract classes and interfaces can contain static member variables , the access type of static member variables in the abstract class can be arbitrary, but the variables defined in the interface can only be public static final type, and the default is public static Final type.
(7) A class may implement multiple interfaces, but only one abstract class can be inherited .

There are also some differences in application: The interface is more in the system architecture design method to play a role, mainly used to define the communication contract between the modules . Abstract classes play a role in the implementation of code, can be implemented code reuse, for example, template method design pattern is a typical application of abstract class, it is assumed that all the servlet classes of a project have to use the same way to determine permissions, log access logs and handle exceptions, It is then possible to define an abstract base class that will allow all servlets to inherit this abstract base class, complete the permission judgments in the service methods of the abstract base class, log access logs and handle the exception code, and only complete their own business logic code in each subclass.

The underlying type and byte size of java.

There are eight basic types of Java, the basic type can be divided into three categories, character type char, Boolean type Boolean and numeric type Byte, short, int, long, float, double. Numeric types can also be divided into integer types, byte, short, int, long, and floating-point number type float, double. There are no unsigned numeric types in Java, and their range is fixed and will not change with the machine hardware environment or the operating system. In fact, there is another primitive type Void in Java, which also has a corresponding wrapper class java.lang.Void, but we cannot manipulate them directly. The 8 type representation ranges are as follows:

byte: 8 bits, the maximum amount of storage data is 255, the stored data range is between -128~127.

Short: 16 bits, maximum data storage is 65536, data range is -32768~32767.

int: 32 bits, the maximum data storage capacity is 2 32 of the square minus 1, the data range is negative 2 of 31 to positive 2 square minus 31.

long: 64 bits, the maximum data storage capacity is 2 64 times minus 1, the data range is negative 2 of 63 to positive 2 square minus 63.

float: 32 bits, data range in 3.4e-45~1.4e38, direct assignment must be preceded by a number F or F.

double: 64 bits, the data range is 4.9e-324~1.8e308, the value can be added D or D can also be added.

Boolean: Only true and false two values are taken.

Char: 16 bits, storing Unicode codes, with single quotation marks.

Java determines the size of each of the simple types. These sizes do not change as the machine structure changes. This immutable size is one of the reasons why Java programs have a strong ability to migrate. The following table lists the simple types defined in Java, the number of bits, and the corresponding wrapper classes.

Hashtable,hashmap,concurrenthashmap Bottom-level implementation principles and thread safety issues?

Can be consulted article: HashMap realization Principle Analysis: http://www.cnblogs.com/lzrabbit/p/3721067.html

Concurrenthashmap Principle Analysis: http://www.cnblogs.com/ITtangtang/p/3948786.html

20. If you do not want to use the tools provided by the Java JDK, you implement a map yourself, what you do. Said for a long time, said HashMap source code, if I do, will learn from the principle of HashMap, said a pass hashmap realization.

What about 21.Hash collisions? What are the methods for resolving hash conflicts?

22.HashMap conflict is very bad, the worst performance, how will you solve? from O (n) to log (n), the idea of a binary sort tree is said.
23.rehash.
24.hashCode () and Equals () generate algorithm, method how to rewrite.

two. Java IO

1. Talk about the common classes in Io, byte stream, character stream, interface, implementation class, method blocking.
2. Talk about NiO.
What is the difference between 3.String encoding UTF-8 and GBK?
4. When to use byte stream, when to use character stream?
5. Recursively read the file under the folder, how the code is implemented.

three. Java Web

1.session and cookie differences and connections, session life cycle, multiple services deployed when session management.
Some of the related issues with 2.servlet.
3.webservice related issues.
4.JDBC connection, forname the steps of the way, how to declare the use of a transaction. Example and specific code.

Reference article: http://www.cnblogs.com/hongten/archive/2011/03/29/1998311.html  

5. Configure the main configuration content of Web. XML without frames.
The difference between 6.jsp and servlet.

Java Development Post interview classification (with answer)

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.