javaSE basic interview questions (2)

1.SQL statement classification
DDL data definition language, DQL data query language, DCL data control language, DML data manipulation language, TCL transaction control language

2. The characteristics of the array
fixed length, the subscript starts from 0, can store any type of data

3. Hash table structure
Array, linked list, red-black tree (jdk1.8)

4. The difference between throw and throws. Throws
is added after the method declaration, allowing multiple exception types at the same time to indicate the possibility of an exception. As a reminder to the caller, it will not cause an exception.
Throw is used in the method body, followed by the exception Object, can only throw one exception at the same time, is the producer of the exception, the thrower

5. The difference between == and equals.
For values: only use "= =" to compare, there is no equals method.
For reference data types, if the equals method is not overloaded, the comparison is the memory address

6. Calling static code blocks is mainly used for class initialization

7. Subquery
A query statement includes at least two select statements

8. Stream Flow
direction: input stream output stream, unit: byte stream character stream, function: node stream processing stream
File stream: byte stream FileInputStream, FileOutputStream,
character stream FileReader, FileWriter,
BufferedInputStream, BufferedOutputStream, BufferedReader, BufferedWriter
objects Stream ObjectInputStream, ObjectOutputScream,
conversion stream: solve garbled codes caused by different encoding formats

9. The difference between
final , finally, and finalize final is used to declare property methods and classes, indicating that properties are immutable, methods cannot be overridden, and classes cannot be inherited.
Finally, it is part of the exception handling statement, and
finalize is always executed as a method of the object class.
This method of the object to be recycled is called when the garbage collector is executed, and this method can be overridden to provide other resource recovery during garbage collection

10. Access modifier permission
private private this class
default default this class this package
protected this class this package and subclass
public public this class this package subclass other packages

11. The difference between
string , stringbuffer and stringbuilder String string constant
StringBuffer string variable (thread safe) High efficiency
StringBuilder string variable (non thread safe)

12. Where is the static code block called?
When the class is first loaded, each static block will be executed in the order of the static block, and will only be executed once

13. The difference between
stack Stack: first-in, last-out, store local variables, basic data types and reference data types
Heap: store new objects of reference data, discontinuous storage space

14. The difference between & and &&
& both sides will be executed
&& the left is false, the right is not executed

15.this, super difference
this refers to the current object, super refers to the object of the parent class, only in the construction method of the class can use this to call another construction method, you can use this. member variable to refer to the member variable (local variable When the name is the same as a member variable)
super calls the parent class’s construction method in the subclass’s construction method, and refers to the parent class’s member variables,
this can be used as the return value of the method, super can not be
this and super can’t be in a static method use

16. Four major characteristics of object-oriented
abstraction, encapsulation, inheritance, polymorphic
encapsulation: class encapsulation: extract the abstraction, and the common features and actors are in the same class to achieve unified management of scattered data, improve security, and provide Creating an object provides a good basic
property encapsulation: when assigning a value to the property, privatize the property, and provide an interface set/get method for external access to improve data security.
Method encapsulation: repetitive data can be extracted and written In one method, it improves reusability, maintainability, and high readability.
Inheritance: subclasses can reuse the attributes and methods of the parent class, which improves the reusability of data. It is an incremental development. Under the circumstances, the method of the parent class can not meet the needs of the subclass can be rewritten.
Polymorphism: a thing has multiple manifestations.
Compile-time polymorphism: polymorphism that can be completed at compile time, such as method overloading ( The same method name parameter list can show different forms)
Runtime polymorphism: In the inheritance relationship, the parent class references the entity of the subclass, and the upward transformation can reduce duplication and improve code reusability, such as rewriting , The parent class has a method, and the subclass also has a method. When creating a subclass object in an upward transformation manner, use the object name of the parent class to call the subclass to rewrite the subsequent method

Guess you like

Origin blog.csdn.net/Echoxxxxx/article/details/111656335