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

An example Analysis of JAVA basic interview questions

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article shares with you the content of the sample analysis of the basic JAVA interview questions. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The difference among final, finally and finalize in 1.Java

Simple differences:

Final is used to declare properties, methods, and classes, indicating that properties are not interchangeable, methods are not overridden, and classes are not inheritable.

Finally is part of the structure of the exception handling statement, which means that it is always executed.

Finalize is a method of the Object class that is called when the garbage collector executes for other resources during garbage collection, such as closing files, etc.

What's the difference between 2.error and exception?

Error (errors) represent system-level errors and exceptions that programs do not have to handle, internal errors or hardware problems in the java runtime environment. For example: insufficient memory resources and so on. For this error, the program is basically powerless and has no choice but to quit running, which is thrown by the Java virtual machine.

Exception (violation) refers to the exception that needs to be caught or handled by the program. it deals with problems caused by defects in program design or general problems caused by external input, which the program must deal with.

Exception is divided into run-time exceptions and checked exceptions.

Run-time exceptions, which represent exceptions that cannot be recovered by the program, usually because the wrong operation has been performed and it is recommended to terminate the program, so the compiler does not check for these exceptions.

The checked exception is the exception that the program can handle, that is, the program can fix it (the program accepts the exception and handles it), so it is called the checked exception.

Elements in 3.Set cannot be repeated, so what method is used to distinguish whether they are repeated or not? Do you use = = or equals ()? What's the difference between them?

1. What is Set? (what)

Set is a subinterface of the Collection container, which does not allow duplicate elements and, of course, only one null object.

2. how to distinguish between repetition and non-repetition? (how)

"use the iterator () method to distinguish between repetition and non-repetition", this is the answer circulated on the Internet, I think this is a wrong answer. It is clear in JPI: "set does not contain satisfaction."

The elements of e1.equals (e2) pair E1 and e2 ", so it is more appropriate to use equals () to distinguish the answer.

3. Why use equals () instead of = = to distinguish? (why)

We should start with the difference between the two. = = is used to determine whether the two are the same object (the same thing), while equals is used to determine whether the same object is referenced or not. Take another look at whether the object is stored in the Set or whether it is a reference to the object. According to the storage mechanism of Java, what is stored in set is a reference to an object, so when two elements already point to the same object as long as they satisfy equals (), there are duplicate elements. So we should use equals () to judge.

Static Nested Class (static nested class) is a kind of Inner Class (inner class).

Static Nested Class is an inner class that is declared static (static) and can be instantiated without relying on external class instances. The usual inner class can only be instantiated after the external class is instantiated.

The difference between Overload and Override?

Override is overridden: the method name, number of parameters, type, order, and return value type must all be the same as the parent class method. Its relationship is a father-son relationship.

Overload is overloaded: the method name remains the same, and the rest can be changed. Its relationship is the same class, the same method name, different method parameters, or return values.

Note: they are all different manifestations of Java polymorphism.

Whether the constructor constructor can be override

1.Constructor cannot be inherited, so Constructor cannot be override, but it can be overload, so you can see that there are multiple constructors.

two。 No, each class must have its own constructor, which is responsible for constructing its own part.

The subclass does not override the constructor of the parent class, but must be responsible for calling the constructor of the parent class in the first place

What are the characteristics of List, Map and Set when accessing elements?

List holds elements in a specific order, but there are repeating elements. That is, orderly and repeatable.

Set cannot have repeating elements, internal sorting. That is, disorder cannot be repeated.

Map saves key-value values, and value can have multiple values. Mapping one by one.

The difference between Hashtable and HashMap:

Are classes that belong to the Map interface and implement mapping unique keys to specific values.

The HashMap class has no classification or sorting. It allows a null key and multiple null values.

Hashtable is similar to HashMap, but null keys and null values are not allowed. It is also slower than HashMap because it is synchronized.

Dynamic include and static include in jsp

When using dynamic INCLUDE, the page to be included (included.jsp in your example) will be parsed first and displayed together with the main page after parsing.

When using static INCLUDE, it does not parse the page to be included (included.htm in your example), that is, no matter what is in your included.htm, my task is to include and display you, regardless of the rest.

Jsp:include compiles the included.jsp file first, then includes it first, and then includes @ include. It includes the file first, and then compiles it uniformly.

The difference between forward and redirect in Java

When using forward, the browser does not know the specific source of the resource it requests, so the address bar will not change.

Using redirect, the server logically sends a status code that tells the browser to request that address again. So the address bar shows the new URL.

Forward, the forwarding page and the forwarded page can share the data in the request.

Redirect, cannot share data.

What are the built-in objects in jsp?

1.request-- > request that triggers the service invocation-- > scope: request

2.response-- > reply to request-- > scope: page

3.session-- > session object created for the requesting customer-- > scope is: session

4.application-- > the servlet context obtained from the servlet configuration object (as in the call to getServletConfig () getContext ())-- > scope is: application

5.out-- > object to write to the output stream-- > scope: page

6.pageContext-- > the page context of this JSP-- > scope is: page

7.page-- > implement an instance of the class that handles the current request on this page-- > page

8.config-- > ServletConfig of this JSP-- > page

9.exception-- > indicates the exception that occurs when the JSP page is running-- > Page

Servlet Lifecycle:

Servlet load-> instantiate-> Service-> destroy.

1. The initialization phase calls the init () method

2. Call the service () method in response to the customer request

3. Call the destroy () method in the termination phase

Left join inner join right join distinction

Left\ right join is an external connection, inner join is an internal connection

The external connection includes master table and slave table. The master table is the left side table in left and the right table in right. All the master table data will be displayed, while the slave table data will only show the associated partial matching data, and no matching data will be completed by null.

The inner join only displays the data with matching association conditions of the two tables.

Note: the so-called relevance condition refers to the condition of on.

Common functions of oracle

Oracle SQL provides specialized functions for performing specific operations. These functions greatly enhance the functionality of the SQL language. The function can accept zero or more input parameters and return an output. There are two main types of functions used in Oracle databases:

1. Single-line function: when each function is applied to the record of the table, only one row of results can be entered and one result can be returned.

For example: MOD (XQuery y) returns the remainder of x divided by y (x and y can be two integers or an integer in a table

Series). The commonly used one-line functions are:

Character function: operates on a string.

Numeric function: calculates a number and returns a number.

Conversion function: you can convert one data type to another.

Date function: processes the date and time.

two。 Aggregate function: the aggregate function can operate on multiple rows of data at the same time and return a result. Such as SUM (x)

Returns the sum of x columns in the result set.

An index is a decentralized storage structure created to speed up the retrieval of data rows in a table. Indexes are built on tables and are made up of index pages other than data pages, and the rows in each index page contain logical pointers to speed up the retrieval of physical data.

In the database diagram, you can create, edit, or delete each index type in the Index / key property page of the selected table. When you save the table to which the index is attached, or when you save the diagram where the table is located, the index is saved in the database.

A database index is an identity attached to a table field in order to increase the query speed.

The role of the index:

1. By creating a unique index, the uniqueness of the data record can be guaranteed.

two。 It can greatly accelerate the speed of data retrieval.

3. The connection between meters and tables can be accelerated, which is of special significance in achieving the referential integrity of data.

4. When you use ORDER BY and GROUP BY clauses to retrieve data, you can significantly reduce the time it takes to group and sort in a query.

Thank you for reading! This is the end of the article on "sample Analysis of JAVA basic interview questions". I hope the above content can be of some help to you, so that 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