1. What is the B/s structure? What is the C/s architecture
- b/S (browser/server), browser/server program
c/S (client/server), client/server, desktop applications
2. What do you know about network protocols?HTTP: Hypertext Transfer Protocol
FTP: File Transfer Protocol
SMPT: Simple Mail protocol
TELNET: Remote terminal protocol
POP3: Mail Read protocol
What are the development platforms for 3.Java?
JAVA SE:主要用在客户端开发JAVA EE:主要用在web应用程序开发JAVA ME:主要用在嵌入式应用程序开发
4. What is a JVM? What does a Java virtual machine include?
Jvm:java virtual machines, using hardware or software means to implement virtual computers, Java Virtual machines include: registers, stacks, processors
Does 5.Java require developers to recycle memory waste?
Most of the cases are not needed. Java provides a system-level thread to track memory allocations, and memory areas that are no longer used will be automatically recycled
6. What is a JDK? What is a JRE?
Jdk:java Development Kit:java Developer Kit, the environment that developers need to install
Jre:java Runtime Environment:java running environment, Java program needs to install the environment to run
7. What is a data structure?
How the computer saves and organizes the data
What are the 8.JAVA data structures?
线性表(ArrayList)链表(LinkedList)栈(Stack)队列(Queue)图(Map)树(Tree)
9. What is OOP?
Object-Oriented Programming
10. What is object-oriented?
All things in the world can be regarded as an object. Each object consists of dynamic behavior and static properties, which constitute an object.
11. What is the relationship between classes and objects?
A class is an abstraction of an object that is a concrete class, a template for an object, an instance of a class.
There are several data types in 12.Java
整形:byte,short,int,long浮点型:float,double字符型:char布尔型:boolean
13. What is implicit conversion and what is an explicit conversion
A display transformation is a type-strong, forcing a large type of data to be assigned to a small type of data; Implicit conversions are a wide range of variables that accept small-scale data; Implicit and explicit conversions are essentially automatic type conversions and forced type conversions.
Can the 14.Char type be converted to int type? Can be converted to a string type, can be converted into a double type
Char is also a special type in Java, its int value starting from 1, a total of 2 16 data; The Char<int<long<float<double;char type can be implicitly converted to the int,double type. But it cannot be implicitly converted to a string, and a strong turn is required if the char type is converted to the Byte,short type.
15. What is unboxing?
拆箱:把包装类型转成基本数据类型装箱:把基本数据类型转成包装类型
What are the packing classes in 16.Java?
byte:Byte short:Short int:Integer long:Long float:Float double:Double char:Character boolean:Boolean
17. What is included in a Java class?
Properties, methods, inner classes, construction methods, code blocks.
18. For example: if (a+1.0=4.0), so do it?
Not good, because the computer in the floating-point data operation, there will be errors, as far as possible in the Boolean expression does not use floating-point data (If,while,switch to determine the condition does not use floating-point type)
19. How do you solve the problem of errors in floating-point data operations?
Operation of floating-point data using the BigDecimal class
The difference between 20.++i and i++
++i:先赋值,后计算i++:先计算,后赋值
21. What are the structure of the program?
顺序结构选择结构循环结构
22. How are there several ways to instantiate an array?
Static instantiation: When an array is created, the elements in the array are specified,
?
1 |
int [] a= new int []{ 1 , 3 , 3 } |
Dynamic instantiation: When an array is instantiated, only the extent of the array is specified, and all elements in the array are the default values of the array type
Various data defaults in 23.Java
Byte,short,int,long默认是都是0Boolean默认值是falseChar类型的默认值是’’Float与double类型的默认是0.0对象类型的默认值是null
What are the 24.Java popular packages?
Java.langJava.ioJava.sqlJava.utilJava.awtJava.netJava.math
What is the top 25.Java parent class?
Object
What are the common methods of the 26.Object class?
EqualsHashcodetoStringwaitnotifyclonegetClass
Is there a pointer in 27.java?
There are pointers, but hidden, and developers cannot manipulate pointers directly by the JVM to manipulate pointers
is the value pass reference pass in 28.java?
In theory, Java is a reference pass, and for the base data type, the pass is a copy of the value, not the value itself. For object types, passing is a reference to an object, and when a method operates on an action parameter, the object that the reference is directed to is actually manipulated.
29. Suppose that the variable of an instantiated array is treated as a method parameter, and the elements within the array are changed when the method executes, does the array element change outside the method?
Changed because the pass is a reference to the object, the object to which the reference is directed
30. After instantiating an array, can you change the length of the array?
No, once an array is instantiated, its length is fixed.
31. Suppose there are 5 elements in the array, what if the arrays are reversed?
Creates a new array that iterates through each element from the back to the front, placing the extracted elements sequentially into the new array
32. Participate in the actual parameter
Formal parameters, which are all called "formal arguments," are parameters used when defining method names and method bodies, for receiving the actual values that are passed in when the method is called, and the actual parameters, which are all called "actual arguments," and are the real values that are passed to the method when the method is called.
33. Can the construction method be explicitly called?
You cannot construct a method as a normal method call, but it is called by the system only when the object is created.
34. Can the construction method be rewritten? Can it be overloaded?
Can be overridden, or can be overloaded
35. What is method overloading?
The overload of a method is to allow more than one method of the same name to exist in the same class, as long as they have a different number of arguments or types. In this case, the method is called overloaded, and this process is called the overload of the method (override)
36. What is the difference between an inner class and a static inner class?
The static inner class is independent of the outer class, and the variables, methods in the outer class cannot be accessed directly in the static inner class. If you want to access it, you have to new an object of the external class, using the new object to access it. But can directly access static variables, call static methods;
The ordinary inner class exists as a member of the outer class, and the external class property can be accessed directly in the ordinary inner class, calling the method of the outer class.
If an external class is to access the properties of an inner class or invoke a method of an inner class, you must create an object of an inner class that uses that object to access the property or invoke the method.
If other classes want to access the properties of ordinary inner classes or invoke methods of ordinary inner classes, you must create an object of the ordinary inner class in the outer class as an attribute, and the other class can invoke the method of the ordinary inner class or access the properties of the ordinary inner class through this property
If other classes want to access the properties of a static inner class or invoke a method of a static inner class, create a static inner class object directly.
What is the role of 37.Static keywords?
Static can modify inner classes, methods, variables, code blocks
Static-modified classes are statically internal classes
Static methods are static methods that indicate that the method belongs to the current class, but not to an object, and that it cannot be overridden, and can be invoked directly using the class name. The this or Super keyword cannot be used in the static method.
The static modifier variable is either a statically variable or a class variable, and the static variable is shared by all instances and is not dependent on the object. Static variables have only one copy in memory, and when the JVM loads the class, it allocates only one memory at a time.
Static-decorated blocks of code are called Block blocks, which are usually used for program optimization. Code in a static code block executes only once when the entire class is loaded. Static code blocks can have more than one, and if there are multiple, execute sequentially in order.
The role of 38.Final in Java
Final可以修饰类,修饰方法,修饰变量。修饰的类叫最终类。该类不能被继承。修饰的方法不能被重写。修饰的变量叫常量,常量必须初始化,一旦初始化后,常量的值不能发生改变。
What class is used for manipulating strings in 39.Java?
String,stringbuffer,stringbuilder
What's the difference between 40.stringbuffer,stringbuilder?
Both StringBuffer and StringBuilder inherit the Abstractstringbulder class, and Abtractstringbuilder implements the Charsequence interface, and two classes are used for string manipulation.
The efficiency is higher than string when you modify the delete substitution.
StringBuffer is thread-safe and StringBuilder is non-thread safe. So StringBuilder is more efficient than stringbuffer, and most of StringBuffer's methods are added synchronized keywords.
41.String str= "AAA", like string Str=new string ("AAA")?
不一样的。因为内存分配的方式不一样。第一种,创建的”aaa”是常量,jvm都将其分配在常量池中。第二种创建的是一个对象,jvm将其值分配在堆内存中。
42.String str= "AA", String s= "BB", string aa=aa+s; How many objects have you created?
A total of two references, three objects. Because both "AA" and "BB" are constants, the value of the constant cannot be changed, and when the string concatenation is performed, a new constant is created that is "aabbb" and has to be stored in a constant pool.
43. What are the common methods for the math class in Java?
Pow():幂运算Sqrt():平方根Round():四舍五入Abs():求绝对值Random():生成一个0-1的随机数,包括0不包括1
What are the common methods of 44.String classes?
charAt:返回指定索引处的字符indexOf():返回指定字符的索引replace():字符串替换trim():去除字符串两端空白split():分割字符串,返回一个分割后的字符串数组getBytes():返回字符串的byte类型数组length():返回字符串长度toLowerCase():将字符串转成小写字母toUpperCase():将字符串转成大写字符substring():截取字符串format():格式化字符串equals():字符串比较
45. Determine if two objects are the same, can you compare them using Equlas?
No. Equlas are mostly used to make string comparisons, and to determine the basic data type or object type, you need to use = =
What is the difference between 46.== and Equlas?
= = To determine whether the basic data type values are equal, or to determine whether the two objects point to the same memory address, that is to say whether two objects are the same object, Equlas is usually used to do string comparisons.
47. How do I reverse a string?
The reverse method of StringBuilder or StringBuffer
48. What are the characteristics of object-oriented languages?
Encapsulation, inheritance, polymorphism
Whether inheritance in 49.Java is single or multi-inheritance
There are both single and multiple inheritance in Java. There can be only one parent class for Java classes, and for interfaces it is possible to inherit multiple interfaces at the same time
50. What is rewriting? What is overloading?
Overloading and rewriting are all manifestations of Java polymorphism.
Overloading is called override, which behaves in polymorphic form in the same class. When multiple methods of the same name appear in a class, but the number of arguments differs from the parameter type, the method overload is independent of the return value
Rewriting is called overwrite, which is the representation of polymorphism in a character class. When a subclass appears the same way as the parent class, this is the method override. When a method is overridden, the return value of the subclass must be consistent with the parent class. If the parent class method throws an exception, the method that the subclass overrides throws an exception type that cannot be less than the exception type thrown by the parent class.
51. Can the construction method be overloaded? Can you rewrite it?
Can be overloaded and must be overridden
52. If the parent class has only a constructor method, does the subclass have to override the constructor of the parent class?
Must override
53. When you create a subclass object, does the parent class construct the method?
will be executed. When you create a subclass object and call the subclass constructor method, the subclass constructor method calls the parent class's constructor by default.
54. What is a parent class reference to a subclass object?
is a special form of representation of Java polymorphism. Create a parent class reference, and let the reference point to the object of a child class
55. When the parent class references a child class object, the subclass overrides the parent class method and property, and when the property is accessed, whose property is accessed? Whose method is called when the method is called?
Subclasses override the parent class methods and properties, access the properties of the parent class, and call the methods of the subclass
What does 56.Super and this mean?
Super表示当前类的父类对象This表示当前类的对象
57. What are the abstract keywords?
Abstract
58. Should abstract classes have abstract methods?
Not necessary. Abstract classes can have no abstract methods.
59. If there is an abstract method in a class, then this must be an abstract class?
Classes that contain abstract methods must be abstract classes
60. Can an abstract class use final decoration?
No. The definition of an abstract class is for others to inherit, and the final decorated class means that the class cannot be inherited, contrary to the idea of an abstract class.
61. What is the difference between an ordinary class and an abstract class?
普通类不能包含抽象方法,抽象类可以包含抽象方法抽象类不能直接实例化,普通类可以直接实例化
62. What is an interface?
An interface is a statement of some function that is provided externally, and is a special Java class
63.JAVA Why do I need an interface?
Interface compensates for the drawbacks of Java single inheritance
64. What are the features of the interface?
static final修饰的常量接口中所有方法都是抽象方法接口是没有构造方法的接口也不能直接实例化接口可以多继承
65. What is the difference between an interface and an abstract class?
static final修饰的,而抽象的不是
What are the two types of anomalies in 66.Java?
编译时异常运行时异常
67. Say a few common compile-time exception classes?
NullPointerException:空指针异常ArrayIndexOutOfBoundsException:数组下标越界NumberFormatException:数字转换异常IllegalArgumentException:参数不匹配异常InstantiationException:对象初始化异常ArithmeticException:算术异常
68. What are the handling mechanisms for exceptions?
Exception catch: Try...catch...finally, Exception thrown: throws.
69. How to customize an exception
Inherit an exception class, usually Rumtimeexception or exception
70. If an exception occurs when an exception is caught, does the return statement outside the try.catch.finally block execute?
Executes, if there is finally, is executed after finally, if no finally is executed after the catch
Does 71.try.catch.finally have to exist?
Try block must exist, catch and finally can not exist, but not at the same time does not exist
The difference between 72.Thow and THORWS
Throw写在代码块内,throw后面跟的是一个具体的异常实例Throw写在方法前面后面,throws后面跟的是异常类,异常类可以出现多个
What is the difference between 73.Error and exception?
Both error and exception are part of the Java error handling mechanism and inherit the Throwable class.
Exception represents an exception that can be captured by the program or optimized to avoid.
Error indicates a system error and cannot be handled by the program.
74. Does using log4j have any effect on the program?
Yes, log4j is used for logging, logging some key sensitive information, usually logging to a local file or database. Recording in a local file, there are frequent IO operations that can consume some system resources. Logging in the database, the database tables are frequently manipulated, and have a certain impact on system performance. But for program security and data recovery or bug tracking, this resource consumption can be affordable.
How many levels does the 75.log4j log have?
From low to High: Debug, info, Wran, error
76. In addition to using new to create objects, what methods can I use to create objects?
Java Reflection
77.Java is it high efficiency to create objects or create objects from new?
Creating objects with new is more efficient. By reflection, find class resources, use the class loader to create, the process is more cumbersome, so less efficient
How many in the 78.Java collection frame?
Coillection, Map.
What are the set frames under the 79.Collection interface?
List: Linear table, set: Unordered collection.
What are the features of the 80.List interface?
Sequential storage, can have duplicate values.
What are the features of the 81.Set interface?
No storage, no duplicate values.
What is the difference between 82.ArrayList and LinkedList?
ArrayList与LinkedList都实现了List接口。ArrayList是线性表,底层是使用数组实现的,它在尾端插入和访问数据时效率较高, Linked是双向链表,他在中间插入或者头部插入时效率较高,在访问数据时效率较低
What's the difference between 83.Array and ArrayList?
Both arrays and ArrayList are collections of data that are used for storage. The ArrayList is implemented using arrays, but the ArrayList array is encapsulated and expanded, with many features that are not available in native arrays. We can understand that ArrayList is an upgraded version of the array.
What are the characteristics of 84.MAP
以键值对存储数据元素存储循序是无须的不允许出现重复键
Steps for 85.JDBC operation
加载数据库驱动类打开数据库连接执行sql语句处理返回结果关闭资源
86. How to prevent SQL injection from occurring when using JDBC.
Use the PreparedStatement class instead of the statement class
87. How to invoke a stored procedure within JDBC
Using CallableStatement
88. Are you aware of connection pooling and what are the benefits of using connection pooling?
Database connections are very resource-intensive and affect the performance metrics of the program. Connection pooling is used to allocate, manage, and release database connections, allowing applications to reuse the same database connection instead of creating a new database connection each time. Improve program performance by freeing database connections that are idle for long periods of time to avoid connection misses caused by creating too many connections.
89. What are the data source technologies that you know about? What are the benefits of using a data source?
Dbcp,c3p0 and so on, with the most or c3p0, because c3p0 than Dbcp more stable, secure, through the form of configuration files to maintain database information, rather than hard-coded. When the database information of the connection changes, it does not need to change the program code to realize the update of the database information.
What are the two types of IO streams for 90.Java?
According to the function to divide
输入流(input),输出流(output)
According to the type of
字节流,字符流
91. What are the common IO classes?
FileFileInputSteam,FileOutputStreamBufferInputStream,BufferedOutputSreamPrintWriteFileReader,FileWriterBufferReader,BufferedWriterObjectInputStream,ObjectOutputSream
92. The difference between a byte stream and a stream of characters
以字节为单位输入输出数据,字节流按照8位传输以字符为单位输入输出数据,字符流按照16位传输
93.final, Finalize (), finally the nature of different
- Final is the key word;
- Finalize () as the method;
- Finally is the chunk flag, which is used in a try statement;
Role
- Final is the keyword used to identify constants, and the final identified keywords are stored in a constant pool (where the concrete usage of final constants is described below);
- The Finalize () method is defined in object to be invoked by the JVM when the object "disappears" for garbage collection of objects, similar to a destructor in C + +, which frees up resources used by objects (such as i/0 operations) when the user is customized;
- finally{} is used to identify a block of code, with try{}, regardless of whether the code in the try is finished or not executed (meaning there is an exception), the code block of the program will be done;
94. What are the differences between abstract classes and interfaces?
Abstract class:
- Abstract methods, only the concept of behavior, no specific behavior implementation. With the abstract keyword modifier, there is no method body. Subclasses must override these abstract methods.
- The class that contains the abstract method must be an abstract class.
- Abstract classes can only be inherited, and a class can inherit only one abstract class.
Interface:
- All the methods are abstract, and the genera are constants.
- You cannot instantiate, you can define variables.
- An interface variable can refer to an instance of a specific implementation class
- Interfaces can only be implemented, a concrete class implements an interface, and all of the abstract methods must be implemented
- Multiple implementations between interfaces
- A specific class can implement multiple interfaces to achieve multiple inheritance phenomena
95. Methods for Thread synchronization
- Wait (): Let the thread wait. Stores a thread in a thread pool.
- Notify (): Wakes the waiting thread. The first one in the thread pool is usually awakened. Let the awakened thread be in a temporary blocking state.
- Notifyall (): Wakes up all the waiting threads. Wakes all threads in the thread pool.
96. Thread-to-process differences
A process is an independent unit of system resource allocation and scheduling, and threads are the basic unit of CPU dispatch and dispatch.
Relationship of process and thread:
- A thread can belong to only one process, while a process may have multiple threads, but at least one thread.
- A resource is assigned to a process, and all the threads of the same process share all the resources of that process.
- Threads need to be synchronized during execution. Synchronization is achieved between threads of different processes using the means of message communication.
- A thread is an execution unit within a process and a scheduler within a process.
The difference between a thread and a process:
- Dispatch: A thread acts as the basic unit of dispatch and allocation, and processes as the basic unit of resources.
- Concurrency: Not only can concurrent execution between processes, but also concurrent execution between multiple threads of the same process.
- Owning a resource: a process is an independent unit that owns resources, and threads do not own system resources, but can access resources that belong to the process.
- System overhead: When creating or revoking a process, the system is significantly larger than the cost of creating or revoking a thread, because the system allocates and reclaims resources for it. However, the process has a separate address space, and after the process crashes, it does not affect other processes in protected mode, and the thread is just a different execution path in a process. Thread has its own stack and local variables, but there is no separate address space between the threads, a thread dead is equal to the entire process dead, so the multi-process program is more robust than multithreaded programs, but in the process of switching, the cost of large resources, the efficiency is worse.
The difference between 97.& and &&
& is a bitwise operator. && is a Boolean logical operator, and the contents of the preceding false with & processed in the logical judgment are still to be processed, and the subsequent contents are no longer processed with the && processing preceding false.
98. Overloading and rewriting
- Overload is overloaded, overriding overrides and overloads for overriding methods are different manifestations of Java polymorphism. Overrides are a representation of polymorphism between a parent class and a subclass, and overloading is a representation of polymorphism in a class.
- If you define a method in a subclass that has the same name and parameters as its parent, we say that the method is overridden (override). When an object of a subclass uses this method, the definition in the subclass is called, and for it the definition in the parent class is "masked".
- If more than one method with the same name is defined in a class, they either have a different number of arguments or have different parameter types, which is called a method overload (overload).
The overloaded method is a type that can change the return value.
99. If the object's reference is set to NULL, will the garbage collector immediately release the memory occupied by the object?
No, in the next garbage collection cycle, this object will be recoverable.
100. What is the difference between a serial (serial) collector and a throughput (throughput) collector?
The throughput collector uses a parallel version of the new generation garbage collector, which is used for medium-sized and large-scale data applications. The serial collector is sufficient for most small applications, which require about 100M of memory on modern processors.
100 Java Foundation Questions