Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common questions in Java interview questions?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what are the common questions in the Java interview questions". Interested friends might as well take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn what are the common questions in the Java interview questions.

1. Will there be a memory leak in java? please briefly describe it.

Answer: yes; there are useless but reachable objects that cannot be recycled by GC, resulting in memory consumption.

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

A: static variables, also known as class variables, are shared by the whole class. They do not depend on an object and can be accessed directly through the class name, while instance variables must depend on an instance and can only be accessed through the object.

3. Is it possible to make calls to non-static methods from within a static method?

Answer: no, if it contains the method () of the object, the initialization of the object cannot be guaranteed.

4. When you write the clone () method, there is usually a line of code. What is it?

A: Clone has a default behavior: super.clone (), which is responsible for generating the correct size of space and copying it bit by bit.

5. What is GC? Why is there a GC?

Answer: GC means garbage collection (Gabage Collection). Memory processing is a place where programmers are prone to problems. Forgetting or erroneous memory collection will lead to instability or even collapse of the program or system. The GC function provided by Java can automatically monitor whether the object exceeds the scope to achieve the purpose of automatic memory collection. Java language does not provide a display operation method to release allocated memory. Java programmers don't have to worry about memory management because the garbage collector manages it automatically. To request garbage collection, you can call one of the following methods: System.gc () or Runtime.getRuntime (). Gc ().

6. What is the working mechanism of data connection pool?

A: when the J2EE server starts, it establishes a certain number of pooled connections and maintains no less than this number of pooled connections all the time. When the client program needs a connection, the pool driver returns an unused pool connection and records it as busy. If there are currently no idle connections, the pool driver creates a certain number of new connections, and the number of new connections is determined by configuration parameters. When the used pool connection call is complete, the pool driver records the connection table as idle, and other calls can use the connection.

7. The activation mechanism of EJB?

A: take Stateful Session Bean as an example: its Cache size determines the number of Bean instances that can exist in memory at the same time. According to MRU or NRU algorithm, instances migrate between activated and deactivated states. The activation mechanism is when the client calls an EJB instance business method. If the corresponding EJB Object finds that it is not bound to the corresponding Bean instance, it will reply (activate) the instance from its deactivated Bean storage (storing the instance through the serialization mechanism). The corresponding ejbActive and ejbPassivate methods are called before the state transition.

At this point, I believe you have a deeper understanding of "what are the common questions in the Java interview questions?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report