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

The Java class loader includes several types and what is the relationship between them

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

Share

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

This article mainly explains the "Java class loaders including several and the relationship between them is how", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "Java class loaders including several and the relationship between them" bar!

1. Why is Java a platform-independent language?

Platform irrelevance actually means "write once and run everywhere". Java can do this because its bytecode (byte code) can run on any operating system, regardless of the underlying system.

two。 Why isn't Java 100% object-oriented?

Java is not 100% object-oriented because it contains 8 primitive data types, such as boolean, byte, char, int, float, double, long, short. They are not objects.

3. What is singleton class and how do you create a singleton class?

There is only one instance of Singleton class in the same JVM at any time. You can add the constructor to the private modifier to create a singleton.

4. What is polymorphism?

Polymorphism simply says "one interface, multiple implementations". The emergence of polymorphism makes it possible to contract an interface in different fields to provide different functions, specifically, variables, functions or objects can provide multiple functions. Here are two types of polymorphism:

Compile-time polymorphism

Run-time polymorphism

Compile-time polymorphism is mainly about overloading methods (overload), while runtime polymorphism is mainly through the use of inheritance or implementation interfaces.

What is runtime polymorphism, also known as dynamic method allocation?

In Java, run-time polymorphic or dynamic method allocation is a method overload at run time. In this process, the overloaded method is referenced by calling the variable of the parent class. Here is an example:

5. How many kinds of Java loaders are included? What is the relationship between them?

The Java class loaders are:

Bootstrap class loader (bootstrap class loader): loads only the classes needed by JVM itself, with package names starting with java, javax, sun, and so on.

Extended class loader (extensions class loader): loads the class library in the JAVA_HOME/lib/ext directory or by the system variable-Djava.ext.dir to locate the class library in the path.

Application class loader (application class loader): loads class libraries under the system classpath java-classpath or-Djava.class.path.

Custom class loader (java.lang.classloder): a custom class loader that inherits from java.lang.ClassLoader.

Note:-Djava.ext.dirs overrides the ext settings of Java itself, making the built-in JDK feature unavailable. You can specify parameters as follows:

Their relationship is as follows:

Start the classloader, C++ implementation, no parent class.

Extended class loader (ExtClassLoader), Java implementation, parent class loader is null.

Application class loader (AppClassLoader), Java implementation, parent class loader is ExtClassLoader.

Custom class loader, parent class loader is AppClassLoader.

Java learning communication circle: 834962734, join the group to get a free Java architecture advanced technology video. (high concurrency + Spring source code + JVM principle analysis + distributed architecture + micro-service architecture + multithreaded concurrency principle + BATJ interview treasure book)

6. What is a JDBC driver?

JDBC Driver is a kind of software that realizes the interaction between Java application and database. There are four kinds of JDBC drivers:

JDBC-ODBC bridge driver

Native-API driver (partly Java driver)

Network protocol driver (all Java drivers)

Thin driver (all Java drivers)

7. What are the steps to connect to the database using Java?

Register driver class

Create a new database connection

New statement (statement)

Query

Close the connection

8. List the important notes commonly used in Spring configuration.

Here are some important notes:

@ Required

@ Autowired

@ Qualifier

@ Resource

@ PostConstruct

@ PreDestroy

9. What is the Bean in Spring? List the different scopes of Spring Bean.

Bean is the skeleton of Spring application. They are managed by the Spring IoC container. In other words, Bean is an object initialized, assembled, and managed by the Spring IoC container.

Here are five scopes of Spring Bean:

Singleton: only one instance is created per container, which is also the default configuration of Spring Bean. Because it is not thread-safe, make sure that you do not share instance variables in Bean while there are data inconsistencies.

Prototype: create a new instance each time you request it.

Request: same as prototype, except that it is only for Web applications. Create a new instance each time a HTTP request is made.

Session: each time a HTTP session request is received, a new instance is created by the container.

Global Session: create a global Session Bean for each portal application (Portlet App).

Thank you for your reading, the above is the content of "Java class loader includes several kinds and the relationship between them". After the study of this article, I believe you have a deeper understanding of the problem that Java class loaders include several kinds and the relationship between them, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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