On June 3rd, Xindehui Java Internship Interview Summary

Zhuhai Xindehui Beijing Area

In the online video interview notified that day, the mobile phone WeChat video call was used, and the mobile phone was fixed in a place where the computer screen can be photographed. There was no interview environment at the time, but I went anyway. . .

written examination


What is being investigated is the principle of Set. We need to know that the question of investigating Set is actually asking about their characteristics.

    // MyObject 的什么方法会对if表达式的正确性产生影响()(
    public static void main(String[] args) throws Exception {
        Set ts = new TreeSet();
        ts.add(new MyObject("A"));
        if (ts.contains(new MyObject("A"))) {}

In the if is actually to determine whether the Set collection contains the specified object.
The Set interface stores a set of unique, unordered objects. Well, on the surface it is a disorderly loading of different containers. But how is the bottom layer implemented?
[Answer] Determine whether there are elements in ts and the newly created anonymous object are the same. If it is a HashMap, we need to judge equals() and hashCode()

The constructor must have the same name as the class, but the method cannot have the same name as the class

[Construction method] The
method can have the same name as the class name, and the only difference from the construction method is that the construction method does not return a value.


Insert picture description here

Which of the following exceptions is a checked exception and needs to be declared when writing a program ()

[Solution] Throw or catch.

  1. We need to manually capture processing, that is, we use try...catch block to capture processing. Or declare through the throws clause in the method signature
  2. Class not found, file not found, IO exception

The rest are runtime exceptions, which are generally known only at runtime.

Java naming:

下列标识符不合法的有 ()
A.new B.$Usdollars C.1234 D.car.taxi

[Answer] For digital dollars and underscores, D is obviously very irregular, it should be carTaxi in Java, camel case nomenclature

Insert picture description here

What is [Native Class]?

  • Native classes are basic data types
  • Interface can only be publicly statically abstracted and decorated.


Please list the characteristics and isolation level of the transaction, briefly explain the meaning of the isolation level

ACID: Four characteristics of transactions

  • Atomicity
  • Consistency , once rolled back, the data is complete (similar to the total amount of energy in our world is constant, the law of conservation of energy)
  • Isolation isolation , transactions are isolated from each other (to ensure that transaction execution is not affected by other transactions as much as possible.)
  • Permanent durability , similar to Taobao once it is received, it cannot be changed

[I dirty read]: The isolation is broken, and transaction A is read by transaction B before it is committed.
[C phantom reading]: In this transaction, transaction A reads data that it has not operated on many times , but it feels looming.
[C Non-repeatable read]: In this transaction, transaction A reads data that it has not operated on many times , but the read results are different/inconsistent or non-existent.

Please briefly describe the difference between Collection and Collections.

Collection is a collection interface , and the main interfaces that inherit it are: List and Set. One of the more important is the implementation of the comparable/comparator interface.
Collections is a tool class . There are many static methods in the source code, which are mainly used to sort the collection, traverse, obtain search, thread safety and other operations.

There are multiple records of id in a table tb, please write a sql to find out all records with this id greater than 2 and show how many records there are in total

select id, count(*) from tb group by id having count(*)>1

Insert picture description here

The user table has three fields: name, sex, and age. Please write a sql to back up the data in the User table to the user_bak table; (database title)

create table user_bak as select * from user;

Create a backup table, just like the original table from the select query.

For a positive integer with no more than 5 digits, the requirements: 1. Find the number of digits, and 2. print out the digits in reverse order. (Programming questions)


Please briefly describe a 4 liter unscaled bucket and a 5 liter unscaled bucket, how to get 3 liters of water? (For logic questions, you can choose one of the questions from Question 27 to answer. If you don’t answer the logic part, you won’t get points)

Fill a 4 liter bucket with water, pour water into the 5 liter bucket, there is 4 liters in the
5 liter bucket, and then fill the 4 liter bucket with water, and then pour water into the 5 liter bucket, this time you can only pour 1 Liters of water, the remaining water in the 4 liter bucket will die 3 liters

Practice your hands, it turns out that the interview is like this, and the difference between the information on the face-to-face is quite big