Java
1. What are the aspects of object-oriented features?
1. Abstraction:
Abstraction is to ignore those aspects irrelevant to the current target in a topic, so that you can pay more attention to the aspects related to the current target. Abstraction is not intended to understand all the problems, but to select a part of the problem. Abstract: Process abstraction and data abstraction.
2.
Inheritance:
Follow
It is a hierarchical model linking classes and allows reuse of encouraging classes. It provides a way to clearly express commonalities. A new class of an object can be derived from an existing class. This process is called class inheritance. New category
The new class is called the derived class (subclass) of the original class, and the original class is called the base class (parent class) of the new class ). A derived class can inherit methods and instance variables from its base class, and the class can be modified or added
The new method makes it more suitable for special needs.
3.
Encapsulation:
Encapsulation is to enclose the process and data. Data access can only be performed through the defined interface. Object-oriented computing begins with the basic concept that the real world can be depicted as a series of completely autonomous and encapsulated objects that access other objects through a protected interface.
4.
Polymorphism:
Polymorphism allows different types of objects to respond to the same message. Polymorphism includes parameterized polymorphism and inclusion polymorphism. The polymorphism language has the advantages of flexibility, abstraction, behavior sharing, and code sharing, which effectively solves the same name problem of application functions.
2 is string the most basic data type?
No, it is an object
3 what is the difference between int and integer?
Java
Two different types are available: the reference type and the original type (or the built-in type ). Int
Is Java
The original data type of Integer
Is Java
Int
Provided encapsulation class
4 differences between string and stringbuffer
String
The length is unchangeable,
Stringbuffer
The length is variable. Use
Stringbuffer
If you need
String
, Then use
Stringbuffer
Of
Tostring ()
Method
5. What are the differences between runtime exceptions and general exceptions?
An exception indicates an abnormal state that may occur during the running of the program. An exception indicates an exception that may occur during common operations on the virtual machine. It is a common running error. The Java compiler requires that methods must declare and throw possible non-runtime exceptions, but do not require that they throw uncaptured runtime exceptions.
6. You can name five common classes, packages, and interfaces.
Common classes:
Bufferedreader bufferedwriter filereader filewirter string integer
Common packages: Java. Lang java. AWT java. Io java. util java. SQL
Common interfaces: Remote list map document nodelist
7. Specify the storage performance and features of arraylist, vector, and sorted list.
Both arraylist and vector use numbers.
Data is stored in groups. The number of elements in this array is greater than that in actual storage to add and insert elements. These elements can be indexed directly by serial number, however, inserting elements involves memory operations such as moving array elements.
Because the Synchronized Method (thread-safe) is used to insert data quickly, the performance of the vector is usually worse than that of the arraylist.
The two-way linked list is used for storage. Data indexed by serial number requires forward or backward traversal. However, when inserting data, you only need to record the items before and after this item, so the insertion speed is fast.
8. Design four threads. Two of them increase 1 to J each time, and the other two threads decrease 1 to J each time. Write the program.
The following programs use internal classes to implement threads, and do not consider the sequence when J is added or subtracted.
Public class threadtest1 {
Private Int J;
Public static void main (string ARGs []) {
Threadtest1 TT = new threadtest1 ();
INC Inc = TT. New Inc ();
Dec dec = TT. New Dec ();
For (INT I = 0; I <2; I ++ ){
Thread t = new thread (INC );
T. Start ();
T = new thread (DEC );
T. Start ();
}
}
Private synchronized void Inc (){
J ++;
System. Out. println (thread. currentthread (). getname () + "-Inc:" + J );
}
Private synchronized void Dec (){
J --;
System. Out. println (thread. currentthread (). getname () + "-Dec:" + J );
}
Class Inc implements runnable {
Public void run (){
For (INT I = 0; I <100; I ++ ){
INC ();
}
}
}
Class dec implements runnable {
Public void run (){
For (INT I = 0; I <100; I ++ ){
Dec ();
}
}
}
}
9. built-in JSP objects and methods.
Request request indicates the httpservletrequest object. It contains information about browser requests and provides several useful methods for obtaining cookie, header, and session data.
Response response indicates the httpservletresponse object, and provides several methods (such as cookies and header information) for setting the response to the browser)
The out object is an instance of javax. jsp. jspwriter. It provides several methods for sending output results to the browser.
Pagecontext indicates a javax. servlet. jsp. pagecontext object. It is used to facilitate access to various namespaces and servlet-Related Object APIs, and encapsulates common servlet-related functions.
Session session indicates a requested javax. servlet. http. httpsession object. Session can store user status information
Application applicaton indicates a javax. servle. servletcontext object. This helps you find information about the servlet engine and Servlet environment.
Config config indicates a javax. servlet. servletconfig object. This object is used to access the initialization parameters of the servlet instance.
Page page indicates a servlet instance generated from this page.
10. Write the communication between the client and the server using socket communication. The client must be able to echo the same data after sending the data.
See the socket communication example in the course.
11. Tell the servlet lifecycle and the difference between Servlet and CGI.
After the servlet is instantiated by the server, the container runs its init method, runs its service method when the request arrives, and the service method automatically dispatches the doxxx method (doget, dopost) corresponding to the request, etc, the destroy method is called when the server decides to destroy the instance.
The difference with CGI is that the servlet is in a server process and runs its service method in multi-thread mode. An instance can serve multiple requests, and its instance is generally not destroyed, CGI generates a new process for each request. After the service is completed, it is destroyed, so the efficiency is lower than that of servlet.
12. What technologies are EJB implemented based on? And the difference between sessionbean and entitybean, and the difference between statefulbean and statelessbean.
13. EJB includes (sessionbean, entitybean) telling about their lifecycle and how to manage transactions?
Sessionbean
: Stateless Session Bean
The lifecycle is determined by the container. When the client sends a request, a bean is created.
When
The container does not have to create a new bean
Instead, you can find an existing instance and provide it to the client. When the client calls a stateful Session Bean for the first time
The container must create a new bean in the server immediately.
Instance and associate it with the client. Later, the client calls the stateful Session Bean
The container will dispatch the call to the bean associated with this client.
Instance.
Entitybean
: Entity beans
It can survive for a relatively long time and its status is continuous. As long as the data in the database exists, entity beans
It remains alive. It is not based on the application or service process. Even if the EJB
Container crashed, entity beans
It is also alive. Entity beans
The lifecycle can be used by containers or beans.
Manage by yourself.
EJB
Through the following technical management practices: Object Management Organization (OMG)
(OTs)
), Sun Microsystems
Transaction Service
(JTs
), Java transaction API
(JTA
), Development Team (x/Open
) XA
Interface.
14. What is the working mechanism of the data connection pool?
J2EE
Server
When the server is started, a certain number of pool connections will be established, and a certain number of pool connections will be maintained. When the client program needs to connect, the pool driver returns an unused pool connection and logs its table as busy. If
If there is no idle connection before, the pool driver creates a certain number of connections. The number of new connections is determined by the configuration parameters. After the pool connection call is completed, the pool driver records the connection table as idle.
You can use this connection.
15. Synchronization and Asynchronization have similarities and differences. Under what circumstances should they be used separately? Examples.
If data is shared among threads. For example, if the data being written may be read by another thread or the data being read may have been written by another thread, the data is shared and must be accessed synchronously.
When an application calls a method that takes a long time to execute on an object and does not want the program to wait for the return of the method, asynchronous programming should be used, in many cases, adopting asynchronous channels is often more efficient.
16. What are the app servers?
BEA WebLogic Server
, IBM WebSphere Application Server
, Oracle9i Application Server
, JBoss
, Tomcat
17 what are the collection classes you know? What are the main methods?
The most common collection class is list.
And map
. List
Arraylist
And Vector
They are variable-size lists and are suitable for building, storing, and operating a list of elements of any type of object. List
It is applicable to accessing elements by Numerical index.
Map
Provides a more general method for storing elements. Map
The Collection class is used to store element pairs (called"
Key"
And"
Value"
), Where each key is mapped to a value.
18 here is one for you: Driver A, data source name B, user name C, password D, database table T. Please use JDBC to retrieve all data in table t.
19. How are pages displayed on the JSP page?
Save the following parameters on the page:
Total number of rows: obtain the total number of rows based on SQL statements.
Number of lines per page: Set Value
Current page number: Request Parameters
The page calculates the number of rows in the first row of the current page based on the current page number and number of rows per page, locates the result set to this row, and retrieves the rows of the number of lines displayed on each page.
Database:
1. Differences between stored procedures and functions
A stored procedure is a collection of user-defined SQL statements involving tasks of a specific table or other objects. You can call the stored procedure. A function is usually a database-defined method, it receives parameters and returns some type of values, and does not involve specific user tables.
2. What is a transaction?
A transaction is a series of operations performed by a logical unit. A logical unit of work must have four attributes, called acid (atomicity, consistency, isolation, and persistence) attributes, only in this way can we become a transaction:
Atomicity
A transaction must be an atomic unit of work. modifications to its data must either be performed in all or not.
Consistency
When the transaction is completed, all data must be consistent. In related databases, all rules must be applied to transaction modifications to maintain the integrity of all data. At the end of the transaction, all internal data structures (such as B-tree indexes or two-way linked lists) must be correct.
Isolation
By
Modifications made by a concurrent firm must be isolated from those made by any other concurrent firm. The status of the data when the transaction is viewing the data, either the status before the transaction is modified, or the status of another transaction.
The transaction does not view data in the intermediate state. This is called serializability because it can reload the starting data and replays a series of transactions so that the State at the end of the data is consistent with the state of the original transaction execution.
.
Durability
After the transaction is completed, its impact on the system is permanent. This modification will be maintained even if a system failure occurs.
3. What is the role of a cursor? How do I know that the cursor has reached the end?
The cursor is used to locate the rows in the result set. by determining the global variable @ fetch_status, you can determine whether the result set is reached. Generally, this variable is not equal to 0, indicating that an error or the result set is reached.
4. triggers are divided into pre-trigger and post-trigger. There are differences between these two triggers. What is the difference between statement-level triggering and row-level triggering.
The trigger runs before the trigger event occurs, and the trigger runs after the trigger event. The trigger can obtain the new field values before the event.
A statement-Level Trigger can be executed before or after the statement is executed, and a row-Level Trigger is triggered once for each row affected by the trigger.
Question No: 1
1. Public class test {
Public static void changestr (string Str ){
STR = "welcome ";
}
Public static void main (string [] ARGs ){
String STR = "1234 ";
Changestr (STR );
System. Out. println (STR );
}
}
Please write the output result:
1234
Question No: 2
1. Public class test {
2. Static Boolean Foo (char c ){
3. system. Out. Print (C );
4. Return true;
5 .}
6. Public static void main (string [] argv ){
7. Int I = 0;
8. For (FOO ('A'); Foo ('B') & (I <2); Foo ('C ')){
9. I ++;
10. Foo ('D ');
12 .}
13 .}
14 .}
What is the result?
A
A. abdcbdcb
B. abcdabcd
C. Compilation fails.
D. An exception is thrown at runtime.
Question No: 3
1. Class {
2. Protected int Method1 (int A, int B) {return 0 ;}
3 .}
Which two are valid in a class that extends Class? (Choose two)
A. Public int Method1 (int A, int B) {return 0 ;}
B. Private int Method1 (int A, int B) {return 0 ;}
C. Private int Method1 (int A, long B) {return 0 ;}
D. Public short Method1 (int A, int B) {return 0 ;}
E. Static protected int Method1 (int A, int B) {return 0 ;}
Question No: 4
1. Public class Outer {
2. Public void someoutermethod (){
3. // line 3
4 .}
5. Public class inner {}
6. Public static void main (string [] argv ){
7. Outer o = new outer ();
8. // line 8
9 .}
10 .}
Which instantiates an instance of inner?
A. New inner (); // At line 3
B. New inner (); // At line 8
C. New O. Inner (); // At line 8
D. New outer. Inner (); // At Line 8 // new outer (). New inner ()
Question No: 5
Which method is used by a servlet to place its session ID in a URL that is written to the Servlet's response output stream?
A. The encodeurl method of the httpservletrequest interface.
B. The encodeurl METHOD OF THE httpservletresponse interface.
C. The rewriteurl method of the httpservletrequest interface.
D. The rewriteurl method of the httpservletresponse interface.
Question No: 6
Which two are equivalent? (Choose two)
A. <% = yoshibean. Size %>
B. <% = yoshibean. getsize () %>
C. <% = yoshibean. getproperty ("size") %>
D. <JSP: getproperty id = "yoshibean" Param = "size"/>
E. <JSP: getproperty name = "yoshibean" Param = "size"/>
F. <JSP: getproperty id = "yoshibean" property = "size"/>
G. <JSP: getproperty name = "yoshibean" property = "size"/>
Question No: 7
Which of the following statements regarding the lifecycle of a session bean are correct?
1.
Java. Lang. illegalstateexception is thrown if
Sessioncontext. getejbobject () is invoked when a stateful Session Bean
Instance is passivated.
2. sessioncontext. getrollbackonly () does
Not throw an exception when a session bean with bean-managed
Transaction demarcation is activated.
3. An exception is not
Thrown when sessioncontext. getusertransaction () is called in
Afterbegin method of a bean with container-managed transactions.
4.
JNDI access to Java: COMP/ENV is permitted in all
Sessionsynchronization methods of a stateful session bean
Container-managed transaction demarcation.
5. Accessing Resource
Managers in the sessionsynchronization. afterbegin method of a stateful
Session Bean with bean-managed transaction does not throw an exception.
Part 2: Concept questions
1. Describe the struts architecture? What are the main development tasks of each part?
2. What are the explanations and differences of XML?
3. What built-in objects and actions does JSP have? What are their functions?
4. SQL Q &
Select * from table
And
Select * from table
Where name like '%' and ADDR like '%'
And (incluaddr like '%' or 2_addr like '%'
Or 3_addr like '%' or 4_addr like '% ')
Why are different search results?
5. SQL Q &
Table Structure:
1. Table Name: g_cardapply
Field (field name/type/length ):
G_applyno varchar 8; // application Ticket No. (keyword)
G_applydate bigint 8; // application date
G_state varchar 2; // Application Status
2. Table Name: g_cardapplydetail
Field (field name/type/length ):
G_applyno varchar 8; // application Ticket No. (keyword)
G_name varchar 30; // requester name
G_idcard varchar 18; // requester ID card No.
G_state varchar 2; // Application Status
The joined fields of the two tables are the application form numbers.
Question:
1. query the application date with ID card number 440401430103082
2. query the ID number and number of records with more than two records for the same ID card number
3. Change the application status of the 440401430103082 ID card in both tables to 07.
4. Delete all records surnamed Li in the g_cardapplydetail table