1. Overview Struts, and how Struts implements the MVC architecture?
A: Struts Framework is a Java-based technology. Web application developers can make full use of object-oriented design, code reuse, and "Write once everywelf" through Struts Framework. Struts provides a framework for creating a web application, where the application's display, represented, and backend code of the data are abstract. Struts uses JSP as a view of the MVC, the ActionServlet specified by the ActionServlet as c, which is the interaction between the view and the model. Each entry point of the controller is set by configuration file named struts-config.xml. This file maps the request from the view to a specific Java class for the corresponding processing, and the controller also specifies the location of the next view. The model in Struts mainly refers to JavaBean, which is a representative of the model, the main package data and business logic. Struts processing process:
l The controller performs an initialization work, read the configuration file, initializes the corresponding modulconfig object for different Struts modules.
The controller receives the HTTP request and finds the Action subclass corresponding to the request from the actionConfig. If there is no corresponding action, the controller forwards the request to the JSP or static page, otherwise the controller will distribute the request to the specific action Class is processed.
l Before the Controller calls the specific action Execute method, the ActionForm object will use the parameters in the HTTP request to fill itself. You can also call the Validate method in the ActionForm class to check the legality of the request parameter, and you can return an ActionerRors object that contains all error messages.
l Execute the specific Execute method, it is responsible for performing the corresponding business logic. After execution, return an actionforward object, and the controller is forwarded through the ActionForward object. You can also encapsulate the service logic to be processed in JavaBean. If there is EJB in the system, eJB is called through JavaBean to complete business processing; if there is no EJB, then connect the database directly in the JavaBean to perform database related operations.
2, outline the MVC architecture
A: The MVC includes three types of objects. Model is an application object. The view is a view, and the controller is a controller that defines the user-entered response method.
In the MVC system, models are often referred to as "business logic", which is the code that is really completing the task, and the view is the use of the interface, reflects the changes in data. The controller controls the interaction between the model and the view, which determines what views return to the user, check the information input through the interface and the model for processing the input information.
In the MVC, the denotation and logic layer are separated, and each part can be developed independently of each other, facilitating development and maintenance, and improving development efficiency.
3, multi-threaded advantages
A: You can be divided into two aspects:
l Relative to single thread:
You can respond to the concurrent operation of multiple tasks.
Multithreading cancels the primary loop and turnt detection mechanism, one thread can be paused without blocking the execution of other parts of the system, and when a thread is blocked, only the blocking thread is suspended, all other threads continue to execute.
l Relative to the process: (can answer or answer)
It requires a small overhead, and the conversion cost is small.
All threads share the same address space and cooperate with each other.
Communication between each other is easy.
4, EJB overview
A: EJB is an enterprise-level JavaBean that provides a component model for building enterprise business logic.
EJB is divided into three kinds: session bean, three of which are divided into stateful and stateless session beans, Entity Beans are divided into Entity Bean (CMP) and Bean management Entity Bean. (BMP). Each EJB consists of a remote interface, a local interface, and an EJB container. The remote interface declares a variety of application methods for providing EJB client calls. Local interface declares create the Crete method for creating new EJB instances, looking for EJB instances Find (finder) and removing the REMOVE method of the EJB instance. The EJB container provides EJB's operating environment and life cycle management. 5. Access the Oracle database with Java, get records and output to the interface
answer:……………………..
Class.Forname ("Oracle.jdbc.driver.OracleDriver");
Connection conn = drivermanager.getConnection (URL, UserName, Password);
Statement Stmt = conn.createstatement ();
String str = "SELECT *" ";
ResultSet RS = Stmt.executeQuery (STR);
While (rs.next ())
{
........................
}
Rs.close ();
Stmt.close ();
CONN.CLOSE ();
6, outline Java garbage collection mechanism
A: It works as follows:
When there is no reference to an object, we assume that the object is no longer, the storage unit occupied by the object can be recovered, and the object flag that is no longer referenced can be reclaimed by system.gc () method. Good to null.
7. Can the Java class can inherit, how to achieve more inheritance?
A: Java has no more inheritance, but can achieve more inheritance through the form of an interface.
8, object-oriented characteristics
A: There are three characteristics of object-oriented objects: packages, inheritance, polymorphism. (If you want to answer four, you can add abstract characteristics)
9. What is the advantage of the interface?
A: The interface has the following advantages:
l The interface is just a frame without implementation, so it is not necessary to consider how the method is implemented in the interface when the interface is defined.
l Use the interface to achieve more inheritance.
l Under the premise of exposing the object, expose the programming interface of the object.
l Does not have tooral relationships in the unrelated class (using the adapter).
l Declare one or more methods to do.
10, the difference between arrylist and vector
A: Mainly from two aspects:
l Safety, efficiency
If you want to achieve synchronous security, you have to use the Vector, otherwise use arraylist, because ArrayList does not consider the problem of synchronous security, so efficiency is higher.
l resource
When the capacity of both is full, they will automatically grow their capacity, but the vector is doubled according to their capacity, and ArrayList is increased by 50% of its capacity, so VECTOR can save resources.
11. What is the benefit of this structure in JTABLE?
A, do not store its unit data in the JTable, all instances give their unit value to objects that implement the TableModel interface to maintain and manage, so in the MVC structure, JTable's form is primarily reflected in the role of a V The form is reflected in the data, and the data model reflects the role of M, package data, and business logic.
Note: See the second question 12 in detail, enter a string in the console, then print out in reverse order
A: IMPORT JAVA.IO. *;
Public class test {
Public static void main (string args []) {
String a = "";
String b = "";
String c = "";
Try {
BufferedReader Br = New BufferedReader (NEW INPUTSTREADER (System.in);
IF ((b = br.readline ())! = NULL) {
A = a b;
}
For (int i = str.length () - 1; i> = 0; i -) {
C = C a.substring (i, i 1);
}
System.out.println (c);
}
Catch (Exception E) {
System.out.println (E.getMessage ());
}
}
}
13. Whether Java exists in memory leaks
A: There is existence, when an object references another object, the memory leak will appear when another object is empty.
14, whether the value of the String class can change
A: The value of the String class cannot be changed after initial. If you want to change, it can be converted to a StringBuffer class. This class value is dynamically changed. (Here mainly test String and StringBuffer differences)
15, CORBA Overview
A: General object requesting agent, its main goal is to solve interoperability issues between object-oriented heterogeneous applications and provide some other services required for distributed calculations. ORB is the core of CORBA.
CORBA re-adjusted the relationship between customers and servers. Customers can propose transaction requests to the server, and can also serve as the server role for the next request. Since the CORBA system introduces the concept of the middleware, that is, the event agent completes communication between the client and the server, the server is relatively transparent to the client's position, and the client in the original distributed computer model is canceled. - One correspondence between the server, the CORBA client can dynamically obtain the location of the service object during runtime, and can submit a transaction request for multiple service objects, so it greatly promotes the development of distribution calculations. In addition, the CORBA specification constraint uses an object-oriented distributed method to realize the intact package of internal details in the form of an interface definition language, thereby reducing the complexity of the software system, increasing the reusability of software functions. CORBA provides mapping of advanced languages such as C C C Java, greatly reduces the dependence of programming language.
(To be expanded) 16, JSP built-in object, function, and main method
JSP built-in object function main method
OUT Output Data Print () Println () Flush () Clear () ilyToflush () getBuffersize () close () ............
Request to the client request data getAttributenames () getCookies () getParameter () getParameterValues () setttribute () getServletPath () ............ .....
Response encapsulates the response generated by JSP and then sent to the client to respond to customer request addCookie () sendirect () setContentType () getputstream () getBuffersize () getOutputStream () senderror () getOutputStream () senderror () getoutputstream () senderror () contactshead () ........
Application
Config represents the configuration of the servlet. When a servlet is initialized, the container passes some information to this servlet getServletContext () getServletName () getInitParameter () getInitParameterNameS () ................................... JSP itself, through this can access Flush () .........
PageContext is the context of the JSP page packaging page. Management of the Q forward belongs to the JSP in particular the visible part of the already named object () getAttribute () getException () getRequest () getResponse () getServletConfig () getSession () getServletContext () setAttribute () removeAttribute () findAttribute () ... ..........
SESSION is used to save each user's information in order to track the operating status of each user GetAttribute () getAttributeNames () getCreatetime () getMaxinactiveInterval () invalidate () isnew ()
Exception reflects the exception of running. GetMessage () ............
17. How many modifications are Java? What is the default?
A: (Note: Modifier is a keyword that affects the survival space and accessibility of the class, variables and member methods)
Multi-modifier member method member variable local variable
Abstract √ √ - - - - -
STATIC - √ √ -
PUBLIC √ √ √ -
protected - √ √ -
PRIVATE - √ √ -
Private protected - √ √ -
SYNCHRONIZED - √ - - - - -
Native - √ - - -
Volatile - √ -
Final √ √ √ -
TRANSIENT - √ √
The following is an access control modifier: the default is Friendly modifier similar to the same package of children and grandchildren
PUBLIC √ √ √ √
Protected √ √ √ -
Friendly √ √ - - - -
PRIVATE √ - - - - -
18. Overview of the TOString method
A: Because each class has inherited the Object class, the toString () method is implemented.
The string expression of the created object can be determined by the toString () method.
19, Overview of Object Class
A: The Object class is a superclass of all other classes, and one variable of Object can reference any other class objects. Since an array is implemented as a class, one variable of Object can also reference any array, which includes the following methods: clone () equals () finalize () getclass () hashcode () notify () notifyAll () toString () Wait ()
20, Java Features
A: Java has the following main features:
l simply
l Object-oriented: Java is fully objective, it supports static and dynamic code inheritance and reuse
l Distributed: including data distribution and operational distribution
l Sunday: Java system carefully detects each access to memory, confirming whether it is legal, and when compiling and running programs, you must check the possible problems to eliminate errors. l Structure neutral
l Security: Java does not support pointers, everything to access memory must be implemented by instance variables of the object, which prevents programmers from using Trojan and other spoofing means to access the object's private member, but also avoiding pointer operations. error.
l Albreach with the platform: Java written applications can run on different soft and hard platforms without modification. There are two types of platform-independent: source code level and target code level. Java mainly rely on Java virtual machine to implement platform-independence on the target code level
l Interpretation: When running a Java program, it is first compiled into byte code, the byte code is very similar to the machine code, and the execution efficiency is very high.
l High performance
l
l Dynamics: It allows the program to dynamically load the class required to run.
21, what is an abstract class? What is the difference between the abstract class? Why introduce data interface concepts?
A: With keyword abstract, the class that does not have a fully defined on the content is called an abstract class.
The difference between abstraction and interface is as follows:
1 When you inherit an abstract class, you only need to implement some specific methods and all abstraction methods, and the interface is implemented to implement all the methods in it.
2 There is no member variable in the interface, and there may be a member variable in the abstract class.
Introducing the interface in Java is mainly to solve the problem of multiple inheritance.
22, DOGET and DOPUT?
A: DOPUT will write the address as a file to the server, and the doget will not be displayed only in the address bar.
23. How many ways to synchronize?
A: There are two main methods for achieving synchronization: 1.Synchronized 2.wait notify
Implement multithreading mainly inherits the Thread class and implements Runnable interface.
24. Jump on the JSP page?
A: The JSP page implements the jump mainly has JSP: Forward and Sendredirect two methods.
JSP: Forward: Jump in this container. After jump, the address bar address is unchanged. efficient. End the content of this page immediately after jump.
Sendredirect: Jump between the container, the address bar address is the address after the jump, the efficiency is low.
Jump usually jumps in JSP: Forward.
25, initialization of class variables
A: The class variable in Java must be initialized in the part because the local variable will overwrite the global variable, otherwise the error will be reported: the variable is not initialized. Global variables can be initialized to the specific internal methods or other class members.
26, the definition of arrays
A: Array is implemented as an object. The array element can contain a type value, but the type of each element in the array must be uniformly created as follows:
l declaration
l construct
l initialization
27. The difference between hastable and hashmap?
A: The main difference between HashTable and HashMap is as follows:
l HashTable is synchronized, and hashmap is not synchronized. Therefore, when you don't ask for synchronization, use HashMap high efficiency.
l HashTable version is lower than the HashMap version.
28. Description List and SET distinction
A: The main difference between the two is as follows:
l List is used to handle the sequence, and the SET is used to handle the set.
l. The content in List can be repeated, and the SET is not.