41, can you inherit the String class?
The String class is that the final class cannot be inherited.
42. If SWTICH can act on Byte, whether it can act on long, can it work on String?
Switch (expr1), expr1 is an integer expression. Therefore, the parameters passing to the Switch and the CASE statement should be int, short, char or byte. Long, String can not work on SWTICH.
43, Try {} has a return statement, then the code in finally {} after this try is not executed, when is executed, before returnome or after?
Will be executed, execute before return.
44. Programming: 2 multiplied 8 equal to a few with the most efficient method?
2 << 3
45, the two object values are the same (x.equals (y) == true, but there can be different haveh codes, this sentence is wrong?
No, there is the same Hash Code.
46. After an object is passed as a parameter to a method, this method can change the properties of this object and return the resulting result, then here is the value delivery or reference delivery?
It is a value transfer. Java programming languages only value pass parameters. When an object instance is transmitted to the method as a parameter, the value of the parameter is a reference to the object. The content of the object can be changed in the called method, but the reference to the object will never change.
47. After a thread enters an SYNCHRONIZED method of an object, can other threads can enter other methods of this object?
No, a Synchronized method of an object can only be accessed by one thread.
48. Program: Write a Singleton out.
The main role of the Singleton mode is to ensure that only one example exists in a Java application.
General Singleton mode usually has several forms:
The first form: Define a class, its constructor is private, it has a type of PRIVATE for a Static, an instantimeter of the class initialization, get a reference to it through a public GetInstance method, then call it Methods.
Public class singleton {
Private kindleton () {}
// Is it very strange to define an instance inside yourself?
// Note this is Private only for internal calls
Private static singleleton instance = new singleleton ();
/ / Here is a static method for accessing this Class, you can directly access
Public static singleleton getinstance () {
Return Instance;
}
}
The second form:
Public class singleton {
Private static singleton instance = null;
Public static synchronized singleton getInstance () {
// This method has been improved above, and it is only the first time.
// Generate an instance when using it, improve efficiency!
IF (instance == null)
Instance = new singleleton ();
Return Instance;}
}
Other forms:
Define a class, its constructor is private, all methods are static.
It is generally considered that the first form is more secure.
49, Java interface and the same and different placements of C .
Since Java does not support multi-inheritance, it is possible to use a class or object to use a method or attribute in several classes or objects, and existing single inheritance mechanisms cannot meet the requirements. Compared to inheritance, the interface has higher flexibility because there is no implementation code in the interface. When a class implements an interface, this class is to implement all methods and properties in the interface, and the properties in the interface are all public static below, all methods are public. Public. A class can implement multiple interfaces. 50. Simple principle and application of exception handling mechanism in Java.
When the Java program violates the semantic rules of Java, the Java virtual machine will represent an error as an exception. Violation of semantic rules include 2 cases. One is a semantic check in the Java class library. For example, the array subscript can trigger indexoutofboundsexception; nullpointerException will be triggered when accessing null objects. Another situation is that Java allows programmers to extend this semantic check, and programmers can create their own exceptions and freely choose to trigger exceptions with throw keywords. All exceptions are subclasses of java.lang.thowable.
51, the advantages and principles of garbage collection. And consider 2 recycling mechanisms.
A significant feature in the Java language is to introduce the garbage collection mechanism, which makes the problem of the most headache of C programmers, making the Java programmers no longer need to consider memory management when writing programs. Since there is a garbage collection mechanism, the object in Java no longer has the concept of "scope", and only the reference to the object has a "scope". Garbage recycling can effectively prevent memory leaks, effective use of memory that can be used. The garbage collector is usually operated as a separate low-level thread. In the case of unpredictable objects that have been died or have not used for a long time for a long time for a long time, the programmer cannot call the garbage collector in real time. Object or all objects are garbage collection. The recycling mechanism has a replica collection of garbage collection and marking garbage recovery, incremental garbage recovery.
52. Please tell us how the thread synchronization you know.
Wait (): Make a thread in the waiting state and release the LOCK of the object held.
Sleep (): Make a running thread in sleep state, is a static method, call this method to capture InterruptedException exceptions.
NOTIFY (): Wake up a thread in a waiting state, note that when this method is called, it is not exactly the thread that is awakened, but is determined by the JVM which thread is awake, and is not pressed.
AllNotity (): Wake all threads in the waiting state, not to give all the locks of all awakening threads, but let them compete.
53, what are your collection? Main method?
The most commonly used collections are LIST and MAP. The specific implementation of List includes ArrayList and Vector, which are variable-sized lists, which are more suitable for build, store, and operate any type of objects for any type object. List is suitable for use in value to access elements.
Map provides a more versatile element storage method. The MAP set class is used to store element pairs (called "keys" and "value"), where each key is mapped to a value.
54, describe the principle mechanism of JVM loading Class files?
The loading of the JVM is implemented by ClassLoader and its subclass, and Java ClassLoader is an important Java runtime system component. It is responsible for finding and putting a class file at runtime.
55. Can a Chinese Chinese character can be stored in the char type variable? Why?
It can be defined as a Chinese, because Java is encoded in Unicode, a char accounts for 16 bytes, so putting a Chinese is no problem.
56. There are several implementation methods for multi-threading. What are you doing? How many implementation methods are there?
There are two types of implementation methods, which are two types inherited the THREAD class and the implementation of Runnable interface synchronization, respectively, Synchronized, Wait and Notify
57, the built-in object and method of JSP.
Request represents the HTTPSERVLETREQUEST object. It contains information about the browser request and provides a number of methods for obtaining cookie, header, and session data.
Response represents the HTTPSERVLETRESPONSE object and provides several methods for setting the response to the browser (such as cookies, header information, etc.)
The OUT object is an instance of Javax.jsp.jspwriter, and provides several ways to make you use to return the output results to your browser.
PageContext represents a javax.servlet.jsp.pageContext object. It is an API for convenient access to various range spaces, servlet-related objects, and wraps a generic Servlet related feature.
Session represents a request Javax.Servlet.http.httpSession object. SESSION can store the status information of the user
Applicat represents a Javax.serve.ServletContext object. This helps find information about the Servlet engine and the servlet environment
Config represents a javax.servlet.ServletConfig object. This object is used to access the initialization parameters of the servlet instance.
Page Represents a servlet instance generated from this page
58. The basic concept of thread, the basic state of the thread and the relationship between state
Thread refers to an execution unit that can execute program code during execution, and each program has at least one thread, which is the program itself.
There are four states in Java, respectively, running, ready, hang, and end.
59, common instructions for JSP
<% @ page language = "java" contentYpe = "text / html; charset = GB2312" session = "true" buffer = "64kb" autoflush = "sthreadsafe = true" info = "text" errorpage = "error. JSP "iSerrorPage =" true "iSelignored =" true "pageEncoding =" gb2312 "import =" java.sql. * "%>
iSerrorPage (Can I use an Exception object), iSelignored (ignore expressions)
<% @ include file = "filename"%>
<% @ taglib prefix = "c" uri = "http: // ..."%>
60. What is calling doget () and dopost ()?
The Method property in the FORM tag in the JSP page is called DOGET (), and dopost () is called for POST.