1.int and integer Differences
Java provides two different types: reference types and primitive types. int is the raw data type of Java, and integer is the wrapper class provided by Java for Int. Java provides a wrapper class for each primitive type.
The strings provided by 2.StringBuffer can be modified, and StringBuffer is dynamically constructed with character data.
3. What are the similarities and differences between runtime exceptions and general anomalies
An exception represents an unhealthy state that may occur during a program's run, and a run-time exception that represents an exception that may be encountered in a typical operation of a virtual machine is a common run error.
4.Servlet life cycle, the difference between servlet and CGI
After the servlet is instantiated by the server, the container runs its Init method, forcing it to run its service method when it arrives, and the service method automatically dispatches the run to the request (Doget/dopost
And so on), call its Destroy method when the server decides to destroy the instance.
Unlike CGI, where the servlet is in a server process, it runs its service method in a multithreaded manner, an instance can serve multiple requests, and its instances are generally not destroyed, and CGI generates new progress for each request, which is destroyed after the service is completed, so it is inefficient
The difference between 4.Collection and collections
Collection is the ancestor interface of the collection class, and its interface is mainly set and list
Collections is a helper class for collection classes that provides a series of static methods for searching, sorting, threading, and so on for various collections.
The difference between 5.final,finally,finalize
Final is used to declare properties, methods, and classes, respectively, that the property is not mutable, that methods are not overwritten, that classes are not inheritable
Finally is part of the exception-handling statement structure that always executes
Finalize is a method of the object class that, when executed by the garbage collector, calls this method of the reclaimed object and can override this method to provide garbage collection for other resource recycling, such as closing the file, etc.
6.sleep () and Wait () method differences
In Java, each object has a lock. A thread can use synchrnized to get a lock on an object.
Sleep is the offending thread class (threads) that causes this thread to pause execution for a specified time, but the monitoring State remains, the time arrives automatically replies, and sleep does not release the object lock
Wait () is the method of the object class that calls the wait method on this object to cause this thread to discard the object lock, enter the waiting object's waiting lock pool, and only after the Notify (Notifyall) is issued for this object will the thread enter the object lock pool ready to get the object lock into the running state.
7.error does not expect programs to solve problems, such as memory overflow. Exception is a design or implementation problem
8. What is synchronization
Synchronization refers to the sharing of data between threads, for example, the data being written may be read by another thread, or the data being read may have been written by another thread, which is shared and must be accessed synchronously
9. The difference between abstract class and interface (interface)
What is the difference between 10.Jre and JDK
The Java Runtime Environment (JRE) is the Java virtual machine that will execute the Java program. It also contains the browser plug-in needed to execute the applet. The Java Development Kit (JDK) is a complete Java software development package that includes the JRE, compilers, and other tools that enable developers to develop, compile, and execute Java programs.
The role of 11.static
The Static keyword table name member variable, or member method, can be accessed without an instance variable of the class to which it belongs.
The Java static method cannot be overridden because method overrides are dynamically bound based on the runtime, while the static method is statically bound at compile time. Static variables are classes in Java, and static variables are initialized when the class is airborne on a Java virtual plane.
12 What is a constructor function?
When a new object is created, the constructor is called. Each class has a constructor (the default constructor), and a Java constructor overload means that multiple constructors can be created by a class, and each constructor must have its own unique argument list
13.java does not support multiple inheritance, each class can inherit only one class, but multiple interfaces can be implemented
14. Value passing and reference passing
object is passed by value, which means that a copy of the object is passed, so even if a copy of the object is changed, the value of the source object is not affected
object is passed by reference, meaning that it is not the actual object, but the reference to the object. Therefore, changes made externally to the referenced object are reflected on all objects.
15. Inside the monitor, how to do thread synchronization, what level of synchronization should the program do
Monitors and locks are used in Java virtual machines. The monitor monitors a block of synchronization code, ensuring that only one thread executes the synchronized code block at a time. Each monitor is associated with an object reference, and the thread cannot execute the synchronization code until the lock is acquired.
basic procedures for HTTP requests
The algorithm used in the memory recycling mechanism in Java
18.java Reflection
19. Object-oriented features: abstraction, inheritance, encapsulation, polymorphism
Derived classes can integrate methods and instance variables from a base class, and classes can modify or add new methods to make them more suitable for special needs.
Polymorphism refers to allowing objects of different classes to respond to the same message. Includes parameterization and polymorphism and includes polymorphism, with the advantages of flexibility, abstraction, behavior sharing, and code sharing.
20.String is not a basic type, it is a java.lang.String class, it can not inherit, modify this class, it is the final type.
The 21.GC feature can automatically detect whether an object exceeds the scope to achieve the purpose of auto-reclaiming memory. Java does not provide an explicit action method to release allocated memory. The recycling mechanism has generational replication garbage collection, token garbage collection, and incremental garbage collection.
22. Interfaces can inherit interfaces. Abstract classes can implement interfaces, and abstract classes can inherit entity classes, but entity classes must have explicit constructors.
The abstract method cannot be static,synchronized at the same time.
Constructors can be overloaded
23.JAVA language How to do exception processing, keyword: throws,throw,try,catch,finally what is the meaning of each? Can I throw an exception in a try block?
Java uses an object-oriented approach to exception handling, classifies various exceptions, and provides a good interface. In Java, each exception is an object, which is an instance of the Throwable class or other subclass. When an exception is thrown, a method throws an exception object that contains the exception information, and the method that invokes the object can catch the exception and handle it. Java exception handling is achieved through 5 keywords: try, catch, throw, throws, and finally. In general, a try to execute a program, if an exception occurs, the system will throw (throws) an exception, when you can catch it by its type (catch), or finally (finally) by the default processor to handle. Use try to specify a piece of program that prevents all "exceptions". Immediately following the try program, you should include a catch clause to specify the type of "exception" you want to catch. The throw statement is used to explicitly throw an "exception". Throws is used to indicate the various "exceptions" that a member function might throw. Finally, a piece of code is executed to ensure that a piece of code occurs regardless of the "exception". You can write a try statement outside of a member function call and write another try statement inside this member function to protect the other code. Whenever a try statement is encountered, the "exception" frame is placed on the stack until all the try statements are completed. If the next-level try statement does not handle an "exception", the stack expands until it encounters a try statement that handles this "exception."
24 What is the basic principle of the garbage collector? Can the garbage collector reclaim memory right away? Is there any way to proactively notify a virtual machine for garbage collection?
For GC, when a programmer creates an object, the GC starts to monitor the object's address, size, and usage. Typically, a GC uses a graph to record and manage all objects in the heap. In this way, you determine which objects are "accessible" and which objects are "unreachable." When the GC determines that some objects are unreachable, it is the responsibility of the GC to reclaim those memory spaces. OK. The programmer can manually execute System.GC () to notify the GC to run, but the Java language specification does not guarantee that the GC will execute.
25. What is Java serialization and how do I implement Java serialization?
Serialization is a mechanism for dealing with the flow of objects, so-called object flow is the flow of the object's contents. It is possible to read and write to a Fluidized object, or to transfer the streamed object between the networks. Serialization is a problem that is raised when reading and writing to an object stream. Serialization implementation: Implement the Serializable interface for the class that needs to be serialized, there is no method to implement it, implements serializable just to annotate that the object is serializable, and then use an output stream ( such as: FileOutputStream) to construct a ObjectOutputStream object, followed by the WriteObject (object obj) of the ObjectOutputStream object method to write out (that is, save its state) the object with the parameter obj, and the input stream to restore.
Java Knowledge points