Interview questions 30-day check-in-day01

first day

1. What are JDK, JRE and JVM, and what are the differences?

JDK(Java Development Kit )

JDK is the core toolkit for Java developers. It can also be said that jdk is Java's sdk (software Development Kit software development kit), which includes JRE (Java runtime environment), JVM (Java virtual machine), and Java basic class library. , JavaDoc, jar and other toolkits required by developers.

There are three main versions of JDK:

  1. JavaSE: Java Standard Edition, the version for beginners to learn
  2. JavaEE: Java Enterprise Edition, the version required to develop enterprise-level projects
  3. JavaME: Java Micro Edition, as the name suggests, is suitable for some small device development, such as mobile terminal development, etc.

JRE(Java Runtime Enrivonment)

JRE is the Java runtime environment. If the developer does not have JRE installed, Java programs can be run. JRE also includes JVM, and all Java class libraries.

JVM(Java Virtual Machine)

JVM is a Java virtual machine, which is an environment for Java to run programs. It is used to execute Java bytecode files. The main core is to achieve cross-platform, which can execute programs on different platforms (systems) and improve the portability of Java programs. and security. It also includes functions such as garbage collection and dynamic loading.

relationship between the three

The JDK includes the JRE, and the JRE includes the JVM. The JDK is mainly composed of the RE and the development tools required by Java, and the JRE is composed of the JVM and all Java class libraries.

the difference between the three

  • JDK: Mainly a tool for Java developers
  • JRE: The environment necessary to run Java programs
  • JVM: The core part of the cross-platform, which can run Java applications.

2. What is bytecode? What is the biggest benefit of adopting bytecode?

The bytecode is generated after the source program is compiled by the Java compiler. It is the intermediate code (product) of the Java program. However, the bytecode is only oriented to the JVM. Finally, the JVM mechanism will program the bytecode file into a Java program.

Benefits of using bytecode:

  • Bytecode has good portability and does not depend on the operating system or hardware platform
  • Better implementation of cross-platform
  • Compile once, run in many places.

Java programs are compiled into bytecodes, not directly into machine codes, so Java programs can run on any platform that supports the Java virtual machine. Different operating systems and hardware platforms may require different JVM implementations, but they can all execute the same bytecode program. This cross-platform capability is one of the biggest advantages of Java, which enables Java programs to run on different hardware and operating systems, thus achieving a high degree of portability.

3. What is a database transaction? Tell me about the ACID characteristics of transactions?

A database transaction is a set of logical units of operation that transforms data from one state to another. That is, it is guaranteed that all transactions are 一个工作单元executed, and even if there is a failure, this execution method cannot be changed. When multiple operations are performed in one transaction, either all transactions are committed ( commit), then these modifications are saved in 永久place 放弃; or the database management system will 修改roll back ( ) the entire transaction rollbackto the original state.

ACID characteristics are mainly the following four
  1. Atomicity means that a transaction is an indivisible unit, either all committed or all failed to roll back.

  2. Consistency refers to 合法性状态the transformation of data from one to another before and after transaction execution 合法性状态. This state is 语义上specific rather than grammatical, and is related to specific businesses.

  3. Isolation refers to the execution of a transaction 不能被其他事务干扰, that is, the operations within a transaction and the data used 并发are isolated from other transactions, and the transactions executed concurrently cannot interfere with each other.

  4. Durability means that once a transaction is committed, its changes to the data in the database 永久性的should not be affected by other subsequent operations and database failures. Persistence is 事务日志guaranteed by . The logs include 重做日志and 回滚日志. When we modify the data through a transaction, we will first record the change information of the database in the redo log, and then modify the corresponding rows in the database. The advantage of this is that even if the database system crashes, after the database restarts, the redo logs that have not been updated in the database system can be found and re-executed, so that the transaction is durable.

A database transaction refers to a series of database operations (such as insert, update, delete, etc.), which are either all executed successfully, or all rolled back (undo) to the previous state to ensure the consistency and integrity of the database.

ACID is the main four characteristics of database transactions, including:

  1. Atomicity: A transaction is an atomic operation that is either executed in its entirety or rolled back in its entirety, not just a part of it. If any operation in the transaction fails, the entire transaction must be rolled back to ensure data consistency.
  2. Consistency: Before and after the execution of the transaction, the state of the database must be consistent, that is, the integrity constraints of the database must be met. For example, if the balance of a bank account is 100 yuan, after performing a transfer transaction, no matter whether the transfer operation is successful or not, the sum of the balance of the account should still be 100 yuan.
  3. Isolation: The execution of each transaction should be isolated from each other, and the modification made by one transaction is not visible to other transactions before committing. When multiple transactions are executed concurrently, each transaction should run independently without interfering with each other.
  4. Durability: Once the transaction is committed successfully, the modification to the database is permanent, even if a system failure or other problems occur, these modifications should be preserved. The database should be revertable to the state of the most recent commit. For example, once twelve o'clock in the evening, yesterday is yesterday, and it is impossible to go back to yesterday.

The ACID feature is a key feature of database transactions, ensuring the consistency, reliability and stability of the database. When designing and implementing database systems, special attention should be paid to these characteristics, and appropriate technical means should be used to ensure the correctness and reliability of database transactions.

4. Common tags in HTML

  1. <html>: Defines the root element of the HTML document.
  2. <head>: Defines the head of the HTML document, including the metadata of the document (such as title, description, style sheet, etc.).
  3. <title>: Defines the title of the document, usually displayed in the browser's title bar or bookmark.
  4. <body>: Define the main part of the HTML document, including the content of the web page, images, links, forms, etc.
  5. <h1>- <h6>: Define the HTML title, 1~6 in descending order
  6. <p>: Defines a paragraph, usually used for typesetting text content.
  7. <a>: Define the link, and specify the target address of the link through the href attribute.
  8. <img>: Define the image, and specify the source file path of the image through the src attribute.
  9. <ul>And <li>: Defines unordered lists and list items, typically used to display menus, option lists, etc.
  10. <ol>And <li>: Defines an ordered list and list items, used to display list items in a specific order.
  11. <table>, <tr>, <td>: Define tables, table rows, and table cells for typesetting data.
  12. <form>, <input>, <button>: Define forms, form input fields, and submit buttons for user input and submission of data.
  13. <div>, <span>: define the box model
  14. <script>:JS script tag
  15. <a>: hyperlink label

5. What are the CSS selectors? What are the priorities?

  1. Element selector: Select elements by element name, such as p, , divetc.
  2. Class selector: Select elements by class name, .starting with, eg .class.
  3. ID selector: Select elements by their ID, #starting with, eg #myId.
  4. Attribute selector: Select elements through the attributes of the element, such as [type="text"]selecting all elements whose type attribute value is text.
  5. Pseudo-class selector: Used to select elements with special states, such as :hoverthe state when the mouse hovers over the element.
  6. Descendant selector: It is used to select the descendant elements of the element, such as ul liselecting all li elements under the ul element.
  7. Adjacent sibling selector: used to select adjacent sibling elements, such as h1 + pselecting the p element immediately after the h1 element.
  8. Universal selector: used to select all elements, denoted as *.

In CSS, the priority of a selector is determined by the specificity and importance of the selector. The priority of the selector from high to low is:

  1. !important: Styles with this tag have the highest priority.
  2. Inline style: add the style attribute directly to the element tag to set the style.
  3. ID selector: The style priority of selecting elements by ID is second.
  4. Class selectors, attribute selectors, and pseudo-class selectors: When they have the same specificity, the priority is determined in the order in which they appear.
  5. Element selectors and pseudo-element selectors: lowest priority.

It should be noted that when the selectors have the same priority, the style defined later will override the previous style. When designing CSS styles, you should avoid using them as much as possible !important, and make reasonable use of the specificity and priority of selectors to improve the readability and maintainability of CSS styles.

6. What are the common CSS layouts?

  1. Block-level layout: By setting the element to display: block, the element will occupy a single line and automatically add blank space before and after. It is often used to typesetting paragraphs, titles, navigation bars, etc.
  2. Inline layout: By setting the element to display: inline, the elements will not occupy a single line, but will be arranged sequentially in the same line, which is often used to typesetting links, buttons, labels and other content.
  3. Inline block-level layout: By setting the element to display: inline-block, the element will not occupy a single line, but the width and height can be set, and they are arranged in order in the same line. It is often used to typesetting icons, buttons, etc.
  4. Floating layout: By setting the element to float: leftor float: right, the element is separated from the document flow and floats to the left or right. It is often used to achieve multi-column layout, mixed graphics and other effects.
  5. Flexible box layout: By setting the container element to display: flex, you can set the arrangement direction, alignment, spacing and other attributes of the elements inside the container. It is often used for typesetting navigation bars, card layouts, and responsive layouts.
  6. Grid layout: By setting the container element to display: grid, the elements in the container can be divided into multi-row and multi-column grids, and attributes such as spacing and alignment between the grids can be set. It is often used for complex website layouts and forms. layout etc.

The above are common CSS layout methods. Different layout methods are suitable for different design requirements and scenarios. Choosing the most appropriate layout method according to the actual situation can improve the readability and maintainability of CSS styles.

Guess you like

Origin blog.csdn.net/qq_56098191/article/details/130114021