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 knowledge points you need to know when you interview with Java?

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

Share

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

This article will explain in detail what you need to know about the Java interview, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Multithreading

Basic concept

What is a thread?

Advantages of multithreading

Several implementation methods of multithreading

1. Runnable or Thread?

What is thread safety?

Is Vector, SimpleDateFormat a thread safe class?

What Java prototype is not thread safe?

Which collection classes are thread safe

What is a busy loop in multithreading

How to create a thread

There are several ways to write multithreaded programs.

What are thread local variables

What's the difference between threads and processes? How to communicate between processes and how to communicate between threads

What is pseudo-sharing in multithreaded environment (false sharing)

What are the similarities and differences between synchronous and asynchronous, and under what circumstances do you use them respectively? Give examples to illustrate

Current

The difference between ConcurrentHashMap and Hashtable

The usage of ArrayBlockingQueue, CountDownLatch

What is the concurrency of ConcurrentHashMap?

What's the difference between CyclicBarrier and CountDownLatch? What are their internal principles and usage?

The usage of Semaphore

Thread

Does starting a thread call the run () or start () method? What is the difference between the start () and run () methods

The run () method is executed when the start () method is called, so why can't the run () method be called directly?

Both the sleep () method and the object's wait () method can cause the thread to pause execution. What's the difference between them?

What is the purpose of the yield method? What's the difference between sleep () method and yield () method?

How to stop a thread in Java

Why the stop () and suspend () methods are not recommended

How to share data between two threads

How to force a thread to start

How to pause a running thread for a period of time

What is a thread group and why is it not recommended in Java

How do you call wait (method)? Use if blocks or loops? Why

Life cycle

What are the different thread life cycles?

Thread state, what's the difference between BLOCKED and WAITING

Draw a life cycle state diagram of a thread

What is the purpose of ThreadLocal, what is its principle, and what should be paid attention to when using it?

ThreadPool

What is a thread pool? Why use it?

How to create a Java thread pool

Usage and advantages of ThreadPool

What happens when the thread pool queue is full when the task is submitted?

What's the difference between newCache and newFixed? A brief description of the principle. What is the meaning of each parameter of the constructor, such as coreSize, maxsize, etc.

Implementation Strategy of Thread Pool

There are several ways to close the thread pool, and what are the differences?

What is the difference between the submit () and execute () methods in the thread pool?

Thread scheduling

What is the thread scheduling algorithm used in Java

What is context switching in multithreading

What is your understanding of thread priority?

What is thread scheduler (Thread Scheduler) and time slicing (Time Slicing)

Thread synchronization

Please tell me what you know about thread synchronization.

What is the principle of synchronized?

What's the difference between synchronized and ReentrantLock?

In what scenarios can volatile be used to replace synchronized?

How to make sure that they are executed sequentially when there are three threads of T1, T2 and T3? How to ensure that T2 executes after T1 execution and T3 executes after T2 execution?

What happens when a thread in a synchronous block throws an exception

When a thread enters an object's synchronized method A, whether other threads can enter the object's synchronized method B

What is the difference between using synchronized to modify static methods and non-static methods

How to create a collection of synchronized from a given collection

Lock

What is the Lock interface in Java Concurrency API? What are its advantages over synchronization?

The difference between Lock and Synchronized? What is the advantage of Lock interface over synchronized block

What is ReadWriteLock?

What's the use of the locking mechanism?

What is optimistic lock (Optimistic Locking)? How to achieve optimistic locking? How to avoid ABA problems

Explain the following terms: reorder, spin lock, bias lock, lightweight lock, reentrant lock, fair lock, unfair lock, optimistic lock, pessimistic lock

When should I use a reentrant lock

A brief introduction to the hierarchical method of lock, object lock, class lock

What is the difference between a live lock and a deadlock in Java?

What is a Deadlock? What is the cause of thread deadlock? How to ensure that N threads can access N resources without causing deadlock

The difference between deadlock and live lock, the difference between deadlock and hunger

How to detect whether a thread has a lock

How to realize distributed Lock

What are the unlocked data structures and what is the principle of their implementation?

What application scenarios can read-write locks be used in?

What is the Executors class? The difference between Executor and Executors

What is a Java thread dump (Thread Dump) and how to get it

How to get the thread stack in Java

Name three best practices for using threads in Java

How do you handle uncatchable exceptions in a thread

Examples of multithreading are used in actual projects. What are the common problems you encounter in a multithreaded environment? How did you solve it?

Please describe the methods related to thread synchronization and thread scheduling

There are 3 socket in the program, how many threads are needed to process

If there is a third-party interface and there are many threads to call to get data, it is now stipulated that up to 10 threads call it at the same time, how to do it?

How to find out which thread uses the longest CPU time on Windows and Linux

How to ensure that the thread of the main () method is the last thread of the Java program

There are so many threads (possibly different machines) that need to be coordinated with each other to complete some kind of work. Ask how to design such a coordination scheme.

You need to implement an efficient cache that allows multiple users to read but only one user to write to maintain its integrity. How do you implement it?

Abnormal

Basic concept

What's the difference between Error and Exception?

What is 1.UnsupportedOperationException?

What do 2.NullPointerException and ArrayIndexOutOfBoundException have in common?

What is the checked exception and what is the runtime exception

What are the similarities and differences between runtime exceptions and general exceptions

Briefly describe a runtime exception (runtime exception) that you see most often.

Finally

How to use the finally keyword in exception handling

1. If the method returns a result before executing the finally block, or if the JVM exits, will the code in the finally block still execute?

Is there any return,finally in 2.try still implemented? So will the code in the finally {} immediately after the try be executed? when will it be executed, before or after the return?

3. Under what circumstances will the finally statement not be executed

What's the difference between throw and throws?

OOM, what has happened to you? How did you do it?

SOF, what has happened to you?

Since we can use RuntimeException to handle errors, why do you think there are still checked exceptions in Java

What should you pay attention to when you create an exception class?

The cause of null pointer exception

How to understand the handle or declare principle of exception handling

How to use JUnit to test the exception of a method

Don't write code in the catch block. What's the problem?

Have you ever customized the implementation of exceptions? What does it say?

What is an abnormal chain?

Can an exception be thrown in a try block

JDBC

What are the ways to connect to a database through JDBC

This paper describes the basic steps of operating database with JDBC.

How to deal with transactions in JDBC

What is JdbcTemplate?

What is the DAO module?

How can I improve the performance of reading data when using JDBC to operate the database? How to improve the performance of updated data

List 5 JDBC best practices that should be followed

IO

File

What method is defined in the File type to create a first-level directory

What method is defined in the File type to determine whether a file exists or not

Flow

What streams can be used to improve read and write performance

There are several types of streams in Java

JDK provides some abstract classes for each type of flow to inherit. Which classes are they?

What Istroke O stream is used to manipulate text files

What stream is used for reading and writing to various basic data types and String types

You can specify what is the type of Istroke O stream for character encoding.

Serialization

What is serialization? How to realize Java serialization and matters needing attention

The difference between Serializable and Externalizable

Socket

What does the socket option TCP NO DELAY mean

Which layer of the TCP/IP protocol stack does Socket work at?

The difference between TCP and UDP and the implementation of Java

Tell me a few best practices of IO

What is the difference between a direct buffer and an indirect buffer?

How to read and write ByteBuffer? What is the byte order in ByteBuffer

When you enter a line of n characters from the keyboard with System.in.read (buffer), what is the number of bytes stored in the buffer buffer

How to tokenize using the scanner class (Scanner Class)

Object oriented programming (OOP)

Explain polymorphism, encapsulation, cohesion and coupling.

The realization principle of Polymorphism

What are encapsulation, inheritance and polymorphism

What is the principle of object encapsulation?

Class

What are the ways to get the class object of a class

The difference between overloading (Overload) and rewriting (Override). Can overloaded methods be distinguished according to the return type?

Name several best practices for method overloading in Java

Abstract class

The difference between abstract classes and interfaces

Whether there can be static main methods in abstract classes

Whether abstract classes can implement (implements) interfaces

Whether abstract classes can inherit concrete classes (concrete class)

Anonymous class (Anonymous Inner Class)

Can anonymous inner classes inherit other classes? Whether the interface can be implemented

Inner class

Internal classes are divided into several categories.

Can an inner class refer to a member of its containing class (external class)?

Please tell me why inner classes are introduced in Java? And anonymous inner classes.

Inherit

What is the difference between Inheritance and Aggregation

What's the difference between inheritance and combination?

Why can classes only inherit only and interfaces can inherit more than one?

There are two classes, B inherits AMagi C inherits B, can it convert B to C? Such as C = (C) B

If class an inherits class b and implements interface c, and a variable with the same name is defined in class b and interface c, what will happen?

Interface

What is the interface?

Whether the interface can inherit the interface

Why use interfaces instead of using concrete classes directly? What are the advantages of interface

Generics

What problem is the existence of generics used to solve?

Common characteristics of generics

Can List be converted to List?

Tool class

calendar

The purpose of Calendar Class

How to get an instance of a Calendar Class in Java

Explain some important methods in the calendar class

What is the GregorianCalendar class?

What is the SimpleTimeZone class?

What is the Locale class?

How to format a date object

How to add an hour (hour) to a date object (Date Objects)

How to convert the string YYYYMMDD to a date

Math

What is the purpose of Math.round ()? How much is Math.round (11.5)? How much is Math.round (- 11.5)?

XML

How many forms are there for XML document definitions? What is the essential difference between them? What are the ways to parse XML documents? What's the difference between DOM and SAX parsers?

The way Java parses XML

How to solve the Chinese problem when parsing xml files with jdom? How to analyze

What aspects of XML technology have you used in your project? How to realize

Dynamic agent

Describe several implementation methods of dynamic agent, and point out the corresponding advantages and disadvantages.

About the Java interview need to know which knowledge points to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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