First, let's talk about the differences between final, finally, and finalize.
Final is used to declare attributes. Methods and classes indicate that attributes are unchangeable, methods cannot be overwritten, and classes cannot be inherited.
Finally is a part of the structure of the exception handling statement, indicating that it is always executed.
Finalize is a method of the object class. This method is called when the garbage collector is executed. It can overwrite this method to collect other resources during garbage collection, for example, close a file.
Second, can anonymous inner class (anonymous internal class) be extends (inherited) other classes, or implements (implemented) interface (Interface )?
It can inherit other classes or complete other interfaces. This method is often used in swing programming.
Third, the difference between static nested class and inner class is that the more you say, the better (the more general the interview questions are ).
Static nested class is an internal class declared as static. It can be instantiated without relying on external class instances. In general, internal classes must be instantiated before they can be instantiated.
Fourth, the difference between & and.
& Bitwise operator, indicating bitwise AND operation,
& Is a logical operator that represents logic and (and ).
Fifth, the difference between hashmap and hashtable.
Hashmap is a lightweight Implementation of hashtable (non-thread-safe implementation). They all complete the map interface. The main difference is that hashmap allows null key values ), because of non-thread security, the efficiency may be higher than that of hashtable. hashtable inherits the dictionary interface and hashmap inherits the abstractmap class.
Sixth, the difference between collection and collections.
Collection is the upper-level interface of the Collection class. Its inherited interfaces include set and list.
Collections is a help class for collection classes. It provides a series of static methods for searching, sorting, thread security, and other operations on various sets.
7. When to use assert.
1.4 new keywords (syntax) are used to test the Boolean expression status and can be used to debug programs.
Use assert <Boolean expression> to indicate that if the expression is true, the following statement is executed; otherwise, assertionerror is thrown.
In addition, assert <Boolean expression>: <other expression> indicates that if the expression is true, the subsequent expression is ignored. Otherwise, the value of the subsequent expression is used as the construction parameter of assertionerror.
Note that the-source 1.4 parameter must be added during compilation; otherwise, an error is returned.] Add the-ea parameter during running; otherwise, the assert row is ignored.
Eighth, what is GC? Why does GC exist?
GC is the meaning of garbage collection (gabage collection). Memory Processing is a place where programmers are prone to problems. Forgetting or wrong memory collection can lead to instability or even crash of programs or systems, the GC function provided by Java can automatically monitor whether the object exceeded the scope to automatically recycle the memory. the Java language does not provide a display operation to release the allocated memory.
Ninth, string S = new string ("XYZ"); how many string objects are created?
Two
10. How much is math. Round (11.5? Math. Round (-11.5) and so on?
Math. Round (11.5) = 12
Math. Round (-11.5) =-11
The round method returns a long integer closest to the parameter. After the parameter is added to 1/2, the floor is obtained.
11th, short S1 = 1; S1 = S1 + 1; what is the error? Short S1 = 1; S1 + = 1; what is the error?
Short S1 = 1; S1 = S1 + 1; (the S1 + 1 operation results in int type, which requires forced conversion)
Short S1 = 1; S1 + = 1; (it can be compiled correctly)
12th. What is the difference between sleep () and wait?
Sleep is a thread method, which causes the thread to suspend the execution for a specified time and give the execution opportunity to other threads. However, the monitoring status remains unchanged and will be automatically restored after the time. Calling sleep does not release the object lock.
Wait is an object-class method. Calling the wait method for this object causes this thread to discard the object lock and enter the waiting lock pool for this object. Only the notify method (or notifyall) is issued for this object) then this thread enters the object lock pool and prepares to get the object lock and enters the running state.
13th. Does Java have a goto?
No
Very 13 questions. If any interview asks this question, I suggest you stay away from the company. (End) (job.sohu.com)
14th, does the array have the length () method? Does string have the length () method?
The array does not have the length () method. It has the Length attribute.
String has the length () method.
15th, the difference between overload and override. Can the overloaded method change the type of the returned value?
Overriding and overloading are different manifestations of Java polymorphism. Overriding is a manifestation of the polymorphism between the parent class and the Child class, and overloading is a manifestation of the polymorphism in a class. If a subclass defines a method with the same name and parameter as its parent class, we say this method is overwritten ). When a subclass object uses this method, the definition in the subclass is called. For it, the definition in the parent class is "blocked. If multiple methods with the same name are defined in a class, they may have different numbers of parameters or different parameter types, it is called overloading ). The overloaded method can change the type of the returned value.
16th. The elements in the set cannot be repeated. How can we identify whether the elements are repeated or not? Is = or equals () used ()? What are their differences?
The elements in the set cannot be repeated, so the iterator () method is used to identify whether the elements are repeated or not. Equals () is used to determine whether two sets are equal.
The equals () and = Methods Determine whether the reference value points to the same object equals () is overwritten in the class, in order to return the true value when the content and type of the two separated objects match.
17th. Give me the most common runtime exception.
Arithmeticexception, arraystoreexception, except, failed, cannotredoexception, cannotundoexception, classcastexception, cmcmexception, concurrentmodificationexception, domexception, emptystackexception, failed, illegalstateexception,
Imagingopexception, failed, missingresourceexception, failed, failed, nullpointerexception, profiledataexception, providerexception, rasterformatexception, securityexception, systemexception, undeclaredthrowableexception, unmodifiablesetexception, unsupportedoperationexception
18th, what is the difference between error and exception?
Error indicates that recovery is not a serious problem that is impossible but difficult. For example, memory overflow. It is impossible to expect the program to handle such a situation.
Exception indicates a design or implementation problem. That is to say, it indicates that if the program runs normally, it will never happen.
19th, list, set, and map are inherited from the collection interface?
List, set is
Map is not
20th. What is the difference between abstract class and interface?
The class that declares a method rather than implementing it is called abstract class. It is used to create a class that reflects some basic behaviors and declare a method for this class, however, this class cannot be implemented in this class. You cannot create an abstract instance. However, you can create a variable whose type is an abstract class and point it to an instance of a specific subclass. Abstract constructors or abstract static methods are not allowed. The subclasses of abstract classes provide implementation for all abstract methods in their parent classes. Otherwise, they are also abstract classes. Instead, implement this method in the subclass. Other classes that know their behavior can implement these methods in the class.
An interface is a variant of an abstract class. All methods in the interface are abstract. Multi-inheritance can be achieved by implementing such an interface. All methods in the interface are abstract, and none of them have a program body. The interface can only define static final member variables. The implementation of an interface is similar to that of a subclass, except that the implementation class cannot inherit behaviors from the interface definition. When a class implements a special interface, it defines (to be given by the program body) all the methods of this interface. Then, it can call the interface method on any object that implements the interface class. Because there is an abstract class, it allows the interface name as the type of the referenced variable. Normally, dynamic Association editing will take effect. The reference can be converted to the interface type or from the interface type. The instanceof operator can be used to determine whether the class of an object implements the interface.
21st can abstract methods be both static, native, and synchronized?
None
22nd. Can an interface inherit an interface? Can an abstract class implement the (implements) interface? Can an abstract class inherit a concrete class )?
Interfaces can inherit interfaces. Abstract classes can be implemented (implements) interfaces, and whether abstract classes can inherit object classes, provided that object classes must have clear constructors.
23rd. Is run () or start () used to start a thread ()?
When a thread is started, the START () method is called to make the virtual processor represented by the thread in a running state, which means that it can be scheduled and executed by JVM. This does not mean that the thread will run immediately. The run () method can generate the exit sign to stop a thread.
24th. Can constructor be overwritten?
Constructor cannot be inherited, so overriding cannot be overwritten, but overloading can be overloaded.
25th. Can I inherit the string class?
The string class is a final class, so it cannot be inherited.
26th. After a thread enters a synchronized method of an object, can other threads access other methods of this object?
No. One Synchronized Method of an object can only be accessed by one thread.
27th, there is a return statement in try {}, so will the code in finally {} following this try be executed? When will it be executed, before or after return?
Will be executed, before return.
28th. Programming question: how many equals 2x8 in the most efficient way?
Programmers with a C background are particularly fond of asking such questions.
2 <3
29th, the two objects have the same value (X. Equals (y) = true), but different hash codes are available, right?
No. It has the same hash code.
30th. After an object is passed as a parameter to a method, this method can change the attributes of the object and return the changed result, so is it a value transfer or a reference transfer?
Is the value transfer. The Java programming language only transmits parameters by values. When an object instance is passed as a parameter to a method, the parameter value is a reference to the object. The object content can be changed in the called method, but the object reference will never change.
31st. Does swtich work on byte, long, and string?
In switch (expr1), expr1 is an integer expression. Therefore, the parameters passed to the switch and case statements should be int, short, Char, or byte. Long and string cannot apply to swtich.
32nd programming question: Write a singleton.
The Singleton mode ensures that only one instance of a class exists in a Java application.
The Singleton mode generally has several forms:
The first form: defines a class. Its constructor is private. It has a static private class variable. When the class is initialized, use a public getinstance method to obtain its reference, and then call the method.
Public class Singleton {
Private Singleton (){}
// Define your own instance internally. Isn't it strange?
// Note that this is private for internal calls only
Private Static Singleton instance = new Singleton ();
// Here is a static method for external access to this class, which can be accessed directly.
Public static Singleton getinstance (){
Return instance;
}
}
Second form:
Public class Singleton {
Private Static Singleton instance = NULL;
Public static synchronized Singleton getinstance (){
// This method is better than above. You don't need to generate objects every time. It's just the first time.
// Generate instances during use, improving efficiency!
If (instance = NULL)
Instance = new Singleton ();
Return instance ;}
}
Other forms:
Defines a class. Its constructor is private and all methods are static.
It is generally considered that the first form is more secure.
1. What are the aspects of object-oriented features?
2 is string the most basic data type?
3 what is the difference between int and integer?
4 differences between string and stringbuffer
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.
7. Specify the storage performance and features of arraylist, vector, and sorted list.
Both arraylist and vector use arrays to store data. The number of elements in the array is greater than that in the actual data storage to add and insert elements. They allow the element to be indexed by serial number directly, however, inserting elements involves memory operations such as array element movement, so index data is fast and data insertion is slow. Because vector uses the Synchronized Method (thread-safe), its performance is generally inferior to that of arraylist, the sorted list uses a two-way linked list for storage. Data indexed by serial number needs to be traversed in the forward or backward direction. 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.
Aspect of CORBA
1. What is CORBA? What is the purpose?
A: The CORBA standard is a Common Object Request Broker Architecture, which is standardized by Object Management Group (OMG. It is composed of an Interface Definition Language (IDL), a language binding (binding: also translated as associated encoding), and a protocol that allows interoperation between applications. The purpose is:
Write in different programming languages
Run in different processes
Development for different operating systems
Linux
1. Linux thread and GDI class explanation.
A: Linux implements the "one-to-one" thread model based on the core lightweight process. A thread entity corresponds to a core Lightweight Process, and management between threads is implemented in the off-core function library.
The GDI class is the image device programming interface class library.
Java Huawei interview questions
Java
1. What are the aspects of object-oriented features?
2 is string the most basic data type?
3 what is the difference between int and integer?
4 differences between string and stringbuffer
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.
7. Specify the storage performance and features of arraylist, vector, and sorted list.
Both arraylist and vector use arrays to store data. The number of elements in the array is greater than that in the actual data storage to add and insert elements. They allow the element to be indexed by serial number directly, however, inserting elements involves memory operations such as array element movement, so index data is fast and data insertion is slow. Because vector uses the Synchronized Method (thread-safe), its performance is generally inferior to that of arraylist, the sorted list uses a two-way linked list for storage. Data indexed by serial number needs to be traversed in the forward or backward direction. 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?
14. What is the working mechanism of the data connection pool?
15 synchronization and Asynchronization have similarities and differences. Under what circumstances should they be used separately? Examples.
16 what are the app servers?
17 what are the collection classes you know? What are the main methods?
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
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 is either the status before the transaction is modified or the status after the transaction is modified. The transaction does not view the data in the intermediate status. 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 the same as that 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.
COSCO interview questions
1. Three basic features of object-oriented
2. Concepts and differences between method overloading and method Rewriting
3. Features of interfaces, internal classes, and abstract classes
4. Basic file read/write classes
** 5. Precautions for serialization and how to implement serialization
6. Basic concepts of threads, basic states of threads, and relations between States
7. Thread Synchronization and how to synchronize threads
8. Several common data structures and internal implementation principles.
9. Socket Communication (Differences Between TCP and UDP and JAVA Implementation)
** 10. Java event delegation and garbage collection
11. Basic Steps for JDBC to call the database
** 12. Several Methods and differences for parsing XML files
13. Definition of four basic permissions in Java
14. Java Internationalization
Ii. jsp
1. At least seven implicit objects and their differences must be made.
** 2. Differences between forward and redirect
3. Common JSP commands
3. servlet
1. When do I call doget () and dopost ()?
2. Differences between servlet Init () and service () Methods
3. servlet Lifecycle
4. How to Implement servlet single-thread mode
5. servlet Configuration
6. Four session tracking technologies
4. EJB
** 1. Services provided by the EJB container
It mainly provides declarative cycle management, code generation, continuity management, security, transaction management, lock and release management services.
2. EJB roles and three objects
EJB roles mainly include bean developers, application assemblers, deployers, system administrators, EJB container providers, EJB server providers
The three objects are remote (local) interface, Home (localhome) interface, and Bean class.
2. Several types of EJB
Session Bean, Entity Bean message-driven Bean
Session beans can be divided into stateful and stateless.
Entity beans can be divided into two types: bean management continuity (BMP) and container management continuity (CMP ).
3. Bean instance Lifecycle
Stateless Session Bean, Entity Bean, and message driven bean are generally managed by the buffer pool, while Entity Bean and statefull Session Bean are managed by cache, which usually includes instance creation, set the context, create an EJB object (create), call a business method, and remove. For beans with buffer pool management, the instance is not cleared from the memory after create, instead, the buffer pool scheduling mechanism is used to repeatedly reuse instances. For beans with Cache Management, the activation and deactivation mechanisms are used to maintain the bean status and limit the number of instances in the memory.
4. activation mechanism
Taking statefull Session Bean as an example: the cache size determines the number of bean instances that can coexist in the memory. According to the MRU or NRU algorithm, instances are migrated between the activation and deactivation statuses, the activation mechanism is that when the client calls a business method of an EJB instance, if the corresponding EJB object finds that it is not bound to the corresponding bean instance, it will activate bean storage from it (storage instance through serialization mechanism) reply (activate) this instance. The corresponding ejbactive and ejbpassivate methods are called before the status changes.
5. Main Functions of the remote interface and home interface
The remote interface defines the Business Method for The EJB client to call the business method.
The home interface is used by the EJB factory to create and remove EJB instances.
6. Several basic steps for the client to call the EJB object
1. Set the properties of the JNDI service factory and the JNDI service address system
2. Search for the home interface
3. Call the create method from the home interface to create a remote interface
4. Call the service method through the remote interface
V. Database
1. Writing stored procedures
2. Basic SQL statements
6. WebLogic
1. How to specify the memory size for WebLogic?
In the Weblogic STARTUP script (startservername located in the directory of the corresponding domian server), add set mem_args =-xms32m-xmx200m. You can adjust the minimum memory to 32 MB and the maximum memory to 200 MB.
2. How to set the Weblogic hot start mode (Development Mode) and product release mode?
You can change the Startup Mode of the corresponding server to one of the development or product modes on the console. Or modify the Service Startup File or commenv file and add set production_mode = true.
3. How do I not need to enter the user name and password at startup?
Modify the Service Startup File and add the wls_user and wls_pw items. You can also add encrypted user names and passwords to the boot. properties file.
4. In the Weblogic Management Console, After configuring JMS, EJB, connection pool, and other related information for an application domain (or a website or domain), what files are actually stored in?
The config. xml file stored in this domain is the core configuration file of the server.
5. What is the default directory structure of a domain in WebLogic? For example, a simple helloworld. under the directory where JSP is put, you can enter http: // host: Port Number // helloword in the browser. can JSP view the running result? Another example is how to use a self-written JavaBean?
Domain directory/Server Directory/applications, where the application directory can be accessed as an application. If it is a Web application, the application directory must meet the web application directory requirements, JSP files can be directly placed in the application directory, JavaBean needs to be placed in the application directory of the WEB-INF directory of the classes directory, set the Server default application will be able to achieve in the browser without entering the application name.
6. How do I view the published ejbs in WebLogic?
You can use the console to view all published ejbs in its deployment.
7. How to perform SSL configuration and client authentication configuration in WebLogic or discuss how to configure SSL in J2EE (standard)
Demoidentity is used in the default installation. jks and demotrust. to implement SSL in jks keystore, You need to configure the server to use Enable SSL and configure its port. In product mode, you need to obtain the private key and digital certificate from the CA, and create the identity and trust keystore, load the obtained key and digital certificate. You can configure whether the SSL connection is unidirectional or bidirectional.
8. configuration files required for deploying EJB in WebLogic
Different types of EJB involve different configuration files, all involve configuration files including ejb-jar.xml, weblogic-ejb-jar.xmlCMP entity beans generally also need weblogic-cmp-rdbms-jar.xml
9. Does EJB need to directly implement its business interface or home interface? Give a brief description of the reasons.
The remote interface and home interface do not need to be implemented directly. Their implementation code is generated by the server. The corresponding implementation class in the program running will be used as an instance of the corresponding interface type.
10. Differences between persistent and non-persisten when sending a message Bean in WebLogic
The persistent MDB ensures the reliability of message transmission, that is, if an error occurs in the EJB container and the JMS server still sends the message when the MDB is available, non-persistent messages are discarded.
11. Are you familiar with or have heard of several common J2EE models? And some opinions on the Design Model
Session Facade Pattern: Use sessionbean to access entitybean
Message Facade Pattern: asynchronous call
EJB Command pattern: replace sessionbean with command JavaBeans for Lightweight Access
Data transfer object Factory: Using DTO factory to simplify entitybean data provision features
Generic attribute access: the attibuteaccess interface simplifies entitybean data provision features
Business interface: Use Remote (local) interfaces and bean classes to implement the same interface and standardize business logic consistency
The design of the EJB architecture directly affects the system performance, scalability, maintainability, component reusability, and development efficiency. The more complex the project, the larger the project team, the more important the good design is.
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/kings1108/archive/2009/08/06/4413040.aspx