search
HomeJavajavaTutorialJava interview knowledge points

Java interview knowledge points

Aug 10, 2019 pm 05:47 PM
javainterview

Java interview knowledge points

1. Java files are compiled into bytecode files by JVM, that is, .class files. When the bytecode files are run in different operating systems, the operating system then converts the bytecode files into bytecode files. Code files are compiled into machine code files. This is Java cross-platform


2. First of all, let’s make it clear that java’s GC recycling is completely automatic. There is no relevant API for manual recycling. All memory allocation and recycling permissions are in the jvm and in the developer’s hands. There is no absolute way to force garbage collection, but you can do it like this:

1) For objects that are no longer referenced, assign their references to null in a timely manner. obj = null;

 2) If the memory is really tight, call the System.gc () method to suggest the garbage collector to start collecting garbage and notify the GC to run. However, the Java language specification does not guarantee that the GC will be executed.


3. Default value and value range of java basic types

Integer type byte (1 byte) short (2 bytes) int (4 bytes) long (8 bytes)

Character type char (2 bytes)

Floating point type float (4 bytes) double (8 bytes)

Java interview knowledge points


4. The ASCII code values ​​of common characters are as follows: the ASCII code value of a space is 32; the ASCII code values ​​of numbers 0 to 9 are 48 to 57 respectively; the capital letter "A" The ASCII code values ​​of "Z" are 65 to 90 respectively; the ASCII code values ​​of lowercase letters "a" to "z" are 97 to 122 respectively.


5. Java identifiers have the following naming rules:

1) Composed of 26 English letters in upper and lower case, numbers: 0-9, symbols: _ $ ¥

 2) The identifier should start with letters, _, $.

 3) The identifier cannot be a keyword.


6、Abstract classes and interfaces

 1) About abstract classes

 Before JDK 1.8, the default access permission of abstract class methods was protected

When JDK 1.8, the default access permission of abstract class methods becomes default

 2) About the interface

Before JDK 1.8, the methods in the interface must be public

 JDK In JDK 1.8, the methods in the interface can be public or default. When JDK 1.9, the methods in the interface can be private.

7. Boxing and unpacking Box

The basic data type is converted into a packaging class by boxing (such as: int --> Integer).

Converting a wrapper class into a basic data type is unboxing (such as: Integer --> int).

The wrapper class is the reference type, and the basic data type is the value type.

Through boxing and unboxing operations, a bridge can be built between value types and reference types. In other words, value types and reference types can be easily converted to each other, boxing and unboxing can uniformly examine the system, and any type of value can ultimately be processed as an object.

8. Serialization and deserialization

Java will not instantiate static variables and transient-modified variables during serialization, because static represents members of the class and transient represents objects. Temporary data, it is declared that these two types of data members cannot be serialized

9. Java has two transfer methods, value transfer and reference transfer. Basic types and those created in this way with string str = "aaa"; are all passed by value. Object creation and arrays are all passed by reference, so special attention needs to be paid when judging the formal parameters of the function.

10. Java garbage collection mechanism

Garbage collection is mainly aimed at recycling the heap area, because the memory in the stack area is released along with the thread. The heap is divided into three areas: Young Generation, Old Generation, and Permanent Generation (Method Area).

 1) Young generation: When an object is created (new), the object is usually placed in Young (except for some objects that occupy relatively large memory). After a certain Minor GC (memory recycling for the young generation), it is still Live objects will be moved to the old generation (some specific movement details are omitted).

 2) Old generation: It is the above-mentioned young generation moved over and some larger objects. Major GC (FullGC) is for the collection of the old generation.

 3) Permanent generation: stores final constants, static variables, and constant pools.

11. Package reference

Import java.util.* ;

Can access all classes in the java/util directory, but cannot access the java/util subdirectory All classes under

12. The constructor cannot be inherited, and the constructor can only be called explicitly or implicitly. (This is true both with and without ginseng)

13. Files are divided into text files and binary files. Computers only understand binary, so they are actually different ways of interpreting binary. Text files are characters displayed in different encoding formats, such as Ascii, Unicode, etc. The suffix names of text files in window include ".txt", ".log", source code files of various programming languages, etc. Binary files are text documents. You can't read garbled characters when you open them. As long as the file can be opened with text, it can be regarded as a text file, but the displayed result is not what you want. Binary files can only be read with special applications, such as ".png"," .bmp", etc., most of the files in the computer are still binary files


14. try is only suitable for handling runtime exceptions, while try catch is suitable for handling ordinary runtime exceptions. In other words, if you only use try to handle ordinary exceptions without using catch, the compilation will not pass, because the compiler rigidly stipulates that if ordinary exceptions are caught, they must be explicitly declared with catch for further processing. There is no such provision for runtime exceptions at compile time, so catch can be omitted. It is understandable for the compiler to add catch.


15. Pipeline

For pipelines, there are the following types:

① Ordinary pipeline (PIPE): There are usually two restrictions, one is single Work, that is, it can only be transmitted in one direction; second, blood, which is often used between father and son processes (or between processes with blood relationships).

 ②Stream pipe (s_pipe): The first restriction mentioned above is removed and bidirectional transmission is realized.

  ③Named pipe (name_pipe): Removes the second restriction mentioned above and realizes communication between different processes that are not related by blood.

The requirement is that the communication between different servers must be in full-duplex form, while the pipeline can only be half-duplex. Although it can be bidirectional, there can only be transmission in one direction at the same time. The difference between duplex and half-duplex can be understood as follows:

Java interview knowledge points

Recommended tutorial: Java Basic Introduction Video

Original address: https://blog.csdn.net/qq_33945246/article/details/90040041

The above is the detailed content of Java interview knowledge points. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:CSDN. If there is any infringement, please contact admin@php.cn delete
How does cloud computing impact the importance of Java's platform independence?How does cloud computing impact the importance of Java's platform independence?Apr 22, 2025 pm 07:05 PM

Cloud computing significantly improves Java's platform independence. 1) Java code is compiled into bytecode and executed by the JVM on different operating systems to ensure cross-platform operation. 2) Use Docker and Kubernetes to deploy Java applications to improve portability and scalability.

What role has Java's platform independence played in its widespread adoption?What role has Java's platform independence played in its widespread adoption?Apr 22, 2025 pm 06:53 PM

Java'splatformindependenceallowsdeveloperstowritecodeonceandrunitonanydeviceorOSwithaJVM.Thisisachievedthroughcompilingtobytecode,whichtheJVMinterpretsorcompilesatruntime.ThisfeaturehassignificantlyboostedJava'sadoptionduetocross-platformdeployment,s

How do containerization technologies (like Docker) affect the importance of Java's platform independence?How do containerization technologies (like Docker) affect the importance of Java's platform independence?Apr 22, 2025 pm 06:49 PM

Containerization technologies such as Docker enhance rather than replace Java's platform independence. 1) Ensure consistency across environments, 2) Manage dependencies, including specific JVM versions, 3) Simplify the deployment process to make Java applications more adaptable and manageable.

What are the key components of the Java Runtime Environment (JRE)?What are the key components of the Java Runtime Environment (JRE)?Apr 22, 2025 pm 06:33 PM

JRE is the environment in which Java applications run, and its function is to enable Java programs to run on different operating systems without recompiling. The working principle of JRE includes JVM executing bytecode, class library provides predefined classes and methods, configuration files and resource files to set up the running environment.

Explain how the JVM handles memory management, regardless of the underlying operating system.Explain how the JVM handles memory management, regardless of the underlying operating system.Apr 22, 2025 pm 05:45 PM

JVM ensures efficient Java programs run through automatic memory management and garbage collection. 1) Memory allocation: Allocate memory in the heap for new objects. 2) Reference count: Track object references and detect garbage. 3) Garbage recycling: Use the tag-clear, tag-tidy or copy algorithm to recycle objects that are no longer referenced.

How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log?How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log?Apr 19, 2025 pm 11:45 PM

Start Spring using IntelliJIDEAUltimate version...

How to elegantly obtain entity class variable names to build database query conditions?How to elegantly obtain entity class variable names to build database query conditions?Apr 19, 2025 pm 11:42 PM

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.