In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the basic interview question of Java". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the basic interview question of Java".
Explain several states of threads in a general way.
Runnable: threads are ready to run and may not be able to start execution immediately.
Running: the process is executing the thread's code.
Waiting: the thread is in a blocked state, waiting for the external processing to finish.
Sleeping: threads are forced to sleep.
Blocked on Blocked on O blocking: wait for the operation to complete.
Synchronous blocking (Blocked on Synchronization): wait for the lock to be acquired.
Death (Dead): the thread finishes execution.
What are the basic interfaces in the Java collection class
Collection: represents a set of objects, each of which is its child element.
Set: Collection that does not contain repeating elements.
List: a sequential collection and can contain repeating elements.
Map: you can map keys (key) to objects with values (value). Keys cannot be repeated.
The difference between Iterator and ListIterator
Iterator can be used to traverse Set and List collections, but ListIterator can only be used to traverse List.
Iterator can only traverse the collection forward, and ListIterator can traverse either forward or backward.
ListIterator implements the Iterator interface and includes other functions, such as adding and replacing elements, getting the index of the previous and latter elements, and so on.
The difference between Enumeration and Iterator
All the collection classes in java provide a method to return Iterator, which is an iterator. The main difference between Iterator and Enumeration (enumeration) is that Iterator can delete elements, but Enumration cannot.
When using Iterator to traverse the collection, you should use the remove () method of Iterator to delete the elements in the collection, and use the remove () method of the collection to throw a ConcurrentModificationException exception.
The function of Enumeration interface is duplicated with that of Iterator interface. In addition, the Iterator interface adds an optional remove operation and uses a shorter method name. The new implementation should give priority to using the Iterator interface over the Enumeration interface.
Enumeration is twice as fast as Iterator and takes up less memory. However, Iterator is much safer than Enumeration because other threads cannot modify objects in a collection that is being traversed by iterator.
Introduce the response structure of HTTP
The composition of the request message:
Request method.
The URI of the requested resource.
Protocol version.
Optional request header field.
Content entity.
The composition of the response message:
Protocol version.
Status code.
The reason phrase used to explain the status code.
Optional response header field.
Entity body.
Response:
Response code: respond to whether the client response is successful or not. Such as: 404 (the requested resource could not be found), 500 (server internal error), 200 (successful response), etc.
Message header: the code in which the server communicates with the client, telling the client how to perform certain actions.
Response body: pass the server response to the client to display the content, which can be the download file or the display interface.
The respective roles of final, finalize and finally
Final is a modifier that modifies variables, methods, and classes. If final modifies a variable, it means that the value of the variable cannot be changed after initialization.
The finalize method is a method that is called before the object is reclaimed, giving the object itself a last chance to be resurrected, but there is no guarantee when to call finalize.
Finally is a keyword used in conjunction with try and catch for exception handling. The finally block must be executed, regardless of whether there is an exception in the try block or not.
Tell me about several ways of communication between processes that you know.
Pipeline pipe: a pipeline is a half-duplex communication mode in which data can only flow in one direction and can only be used between related processes. The genetic relationship of a process usually refers to the relationship between a father and a child process.
Advanced pipeline popen: if you start another program as a new process in the current program process, it is considered a child process of the current program. In this way, we become the advanced pipeline mode.
Named pipeline named pipe: named pipeline is also a half-duplex mode of communication, but it allows communication between unrelated processes.
Message queuing MessageQueue: message queues are linked lists of messages, stored in the kernel and identified by message queue identifiers. Message queuing overcomes the shortcomings of less signal transmission information, pipeline can only carry unformatted byte stream and limited buffer size.
Shared memory SharedMemory: shared memory maps a piece of memory that can be accessed by other processes. This shared memory is created by one process, but can be accessed by multiple processes. Shared memory is the fastest IPC mode, and it is specially designed for other inter-process communication modes to run inefficiently. It is often used in conjunction with other communication mechanisms, such as signal two, to achieve synchronization and communication between processes.
Semaphore Semaphore: a semaphore is a counter that can be used to control the access of multiple processes to shared resources. It is often used as a locking mechanism to prevent other processes from accessing a shared resource when it is being accessed. Therefore, it is mainly used as a means of synchronization between processes and between different threads within the same process.
Socket Socket: socket is also an inter-process communication mechanism. Unlike other communication mechanisms, it can be used for different and inter-process communication.
Signal sinal: a signal is a more complex form of communication that notifies the receiving process that an event has occurred.
Thank you for your reading, the above is the content of "what is the basic interview question of Java". After the study of this article, I believe you have a deeper understanding of what the basic interview question of Java is, and the specific use needs to be verified by 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: 215
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.