Java related basic knowledge chooses from Fanlitcn's Blog

xiaoxiao2021-03-06  18

1. What are the object-oriented features 1. Abstraction: Abstract is ignored those aspects that have nothing to do with the current goals in a topic in order to pay more attention to the current goals. Abstraction doesn't plan to understand all the questions, but just choose

Select some of them, temporarily do not use some details. Abstract includes two aspects, one is abstract, and the other is data abstraction. 2. Inheritance: Inherit is a hierarchical model of a linkage, and allows and encourages the reuse of classes, which provides a clear expression of a commonality. A new class of objects can be derived from existing classes.

This process is called class inheritance. New categories inherit the characteristics of the original class, the new class is called the original class (subclass), and the original class is called a new class (parent class). Derived class can be from its

The base class inherits the method and instance variables, and the class can modify or add new methods to make it more suitable for special needs. 3. Package: The package is surrounded by the process and data, and the access to the data can only pass through the defined interface. Object-oriented calculations began in this basic concept, that is, the real world can be depicted into a series of

Fully autonomous, encapsulated objects, these objects access other objects through a protected interface. 4. Polymorphism: Polymorphism means that different class objects are allowed to respond to the same message. Polymorphisms include parameterized polymorphisms and polymorphisms. Polymorphism language is flexible, abstract, behavioral sharing, generation

The advantage of sharing the code is well solved the problem of the application function. 5, String is the most basic data type? Basic data types include Byte, int, char, long, float, double, boolean, and short. The java.lang.string class is final type, so this class cannot be inherited, and this class cannot be modified. In order to improve efficiency, we should use StringBuffer class 6, int and integer to provide two different types: reference types and original types (or built-in types). INT is the original data type of Java, and Integer is a package class provided by Java for INT. Java

Package classes are provided for each original type. Original type package Boolean Boolean CharacterbyTe Byteshortint Integerlong Longfloat Floatdouble Double Reference Type and the original type of behavior is completely different, and they have different semantics. Quote types and original types have different features and usage, including: size and speed

Question, this type is stored in which type of data structure is stored, and the default value specified when the reference type and the original type are used as an instance data of a class. Object reference instance variable default value

NULL, and the default value of the original type instance variable is related to their type. 7, String and StringBuffer Difference Java platform provides two classes: String and StringBuffer, which can store and operate strings, which contain characters data containing multiple characters. This String class provides a value of not

A variable string. The string provided by this StringBuffer class is modified. You can use StringBuffer when you know that character data is changed. Typically, you can

To dynamically construct character data using StringBuffers. 8. Is there an abnormal abnormality in runtime? An abnormality indicates the abnormal state of the program during operation, and the runtime exception indicates an exception that may be encountered in the usual operation of the virtual machine is a common run error. The Java compiler requires that the method must declare that the possible non-running abnormality, but does not require a statement that the abnormality that is not captured. 9. Say the life cycle of the servlet and say 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, the service method automatically dispatches the Doxxx method corresponding to the request (Doget)

, Dopost, etc. When the server determines when the instance is destroyed, it calls its Destroy method. The difference from the CGI is that the servlet is in the server process, which runs its service method by multi-threaded manner, one instance can serve multiple requests, and its instance is generally not destroyed.

And CGI has a new process for each request. After the service is complete, it is destroyed, so it is less efficient than servlet. 10. Say that ArrayList, Vector, LinkedList's storage performance and features ArrayList and Vector are stored in the array mode. The number of elements is larger than actually stored data to increase and insert elements, they all allow direct sequence number index elements.

However, insertion elements should involve memory operations such as array elements, so the index data is fast and inserted, and the vector is used by the SYNCHRONIZED method (thread security).

Can be parsed from ArrayList, and LinkedList uses two-way linked lists to store, pressing data from the serial number index data, but when inserting data, only the front and retrograms are required to record this item.

That is, so the insert is faster. 11, EJB is based on which technologies are implemented? And said the difference between SessionBean and EntityBean, the difference between STATEFULBEAN and STATELESSBEAN. EJB includes session beans, Entity Beans, JNDI, RMI, JAT, etc. SessionBean is used in the J2EE application to complete some server-side business operations, such as accessing the database, calling other EJB components. EntityBean is used to represent the application system

The data used. For clients, SessionBean is a non-persistent object that implements certain business logic running on the server. For clients, EntityBean is a persistent object that represents an object view that stores entities in a persistent memory, or an entity implemented by existing enterprise applications.

. Session Bean can also be subdivided into Stateful Session Bean with Stateless Session Bean, both of which can put system logic

Method is executed, the different is the Stateful session bean to record the state of the caller, so in general, a user will have a corresponding stateful

Sension bean entity. Although Stateless Session bean is also a logical component, he is not responsible for recording the status of the user, that is, when the user calls STATELESS

When the session bean, EJB Container does not look for the specific STATELESS SESSION bean entity to perform this Method. In other words, it is very likely to use several users.

When performing a STATELESS SESSION bean, it is executed in the same bean. From the perspective of memory, Stateful Session bean compares the STATELESS SESSION bean, and the Stateful Session Bean consumes more memory more J2EE Server, but the advantage of the Stateful session bean is

He can maintain the status of the user. 12, the difference between Collection and Collectes. Collection is the superiors of the collection class, inheriting the interface with his interface, mainly SET and List.Collections are a help class for the collection class, and he provides a series of static methods to achieve search, sorting, thread security for various sets. . 13, & and &&. & A bit operator, representing bit and operation, && is a logical operator, representing logic and (AND). 14, the difference between HashMap and Hashtable. HashMap is a lightweight implementation of HashTable (non-thread security), they all completed the MAP interface, mainly differentiated by the HashMap allows empty (NULL) key value (key), by

At non-threaded security, efficiency may be higher than HashTable. Hashmap allows null as a key or value of Entry, while HashTable is not allowed. Hashmap removes the HashTable's Contains method, changed to ContainSvalue and Containskey. Because the Contains method is easy to cause misunderstandings. HashTable inherits from the Dictionary class, and HashMap is an implementation of the Map Interface introduced by Java 1.2. The biggest difference is that the HashTable method is Synchronize, and Hashmap is not, when accessing the HashTable in multiple threads, does not need to be synchronized for its method, and hashm

AP must provide external synchronization. Hash / rehash algorithms used by HashTable and Hashmap are probably, so performance will not have a big difference. 15, Final, Finally, Finalize distinction. Final is used to declare attributes, methods, and classes, indicate that attributes are unambiguous, and the method is not covered, and the class cannot be inherited. Finally is part of an exception handling statement structure, which is always executed. Finalize is a method of the Object class. When the garbage collector is executed, this method of recycling object is called, which can overwrite this method to provide other resource recovery when garbage collection.

Such as turning off files, etc.. 16, SLEEP () and WAIT () What is the difference? Sleep is a thread method, causing this thread to suspend the specified time, give other threads, but the monitoring status remains, it will automatically recover .

Calling SLEEP does not release the object lock. WAIT is the method of the object class. Call the WAIT method for this object causes the lecture to abandon the object lock, enter the waiting lock pool waiting for this object, only the NOTIFY method is issued for this object (or N

OtifyAll) After the thread enters the object locking pool, ready to obtain the object lock into the operating state. 17, the difference between overload and override. Can OVERLOADED methods change the type of return value?

The method of rewriting Overriding and overloading overloading is a different manifestation of Java polymorphism. Overriding Overriding is a manifestation of polymorphism between parent class and subclasses, and overloading overloading is a manifestation in a class. If a method is defined in the subclass with the same name and parameters as its parent class, we say that this method is overriddled. Sub-class object use

When this method, the definition in the subclass will be called. For it, the definition in the parent class is as "shielded". If multiple ways of the same name are defined in a class, they have different parameters

Number or have different parameter types, called Overloading. The way OVERLOADED is to change the type of return value. 18. What is the difference between ERROR and EXCEPTION? Error indicates a serious problem that recovery is not impossible but difficult. For example, memory is overflow. It is impossible to expect the program to handle this situation. Exception represents a design or implementation problem. That is, it means that if the program runs normally, it will never occur. 19 for example. If the data will be shared between the thread. For example, the data being written may be read by another thread, or the data being read may have been written by another thread, then these numbers

According to sharing data, you must perform synchronous access. When the application calls a method that takes a long time to perform, it should be used asynchronous programming when the method is called for a long time, and does not want to let the program wait for the method of returning, in many cases

Using asynchronous pathways tend to more efficient. 20. What is the difference between Abstract Class and Interface? The presence of a declaration method does not implement its class called an abstract class, which is used to create a class that reflects certain basic behaviors and declares the class declaration method. , but

This class cannot be implemented in this class. An instance of the Abstract class cannot be created. However, you can create a variable, which is an abstract class and let it point to one instance of the specific subclass.

. There is no abstract constructor or abstract static method. Subclasses of the Abstract class provide implementation for all abstraction methods in their parent class, otherwise they are also abstract classes. Instead, in the child

This method is implemented in the class. Other classes that know their behavior can be implemented in the class. Interface is a variant of an abstract class. In the interface, all methods are abstract. Multiple inheritance can be obtained by achieving such an interface. All methods in the interface are abstract

There is no program body. The interface can only define the Static Final member variable. The implementation of the interface is similar to the subclass, except that the implementation class cannot inherit behavior from the interface definition. Class implementation

When special interfaces, it defines (that is, it is about to give the program) all such interfaces. Then, it can call the interface to call the interface on any object of the class of the interface. Due to abstract

Class, which allows the interface name as the type of reference variable. The usual dynamic cable will take effect. The reference can be converted to an interface type or switch from the interface type, the InstanceOf operator can be used.

To determine if the class of an object has implemented an interface. 21, what is the difference between Heap and Stack. The stack is a linear set, and the operation of adding and deleting elements should be completed in the same paragraph. The stack is processed in the way in which it is advanced. Stack is a constituent element 22, forward and redirect's difference Forward is a server request resource. The server directly accesses the URL of the target address, reads the URL's response content, and then send these content to the browser, browser fundamental

I don't know where the server sent is from, so it is still the original address in its address bar. Redirect is the server according to the logic, send a status code, telling the browser to re-request that address, generally saying that the browser re-requests all the parameters just requested, so session, the request parameter can be obtained. 23, the difference between EJB and Java Bean? Java bean is a reused component that does not have a strict specification for Java Bean. In theory, any Java class can be a bean. But usually, due to Java

The bean is created by the container (such as Tomcat), so Java Bean should have a 11th constructor, in addition, usually Java

Bean also implements the Serializable interface to implement the persistence of beans. Java Bean is actually equivalent to the COM component in the local process in the Microsoft COM model, which cannot be accessed across the process

of. Enterprise Java Bean is equivalent to DCOM, ie distributed components. It is based on Java-based remote method call (RMI) technology, so EJB can be remotely accessed (cross progress, cross

computer). But EJB must be deployed in a container such as WebSpere, WebLogic, and EJB customers never access true EJB components, but access them through their container. EJB container

It is an agent of the EJB component, and the EJB component is created and managed by the container. The client accesses the real EJB component through the container. 24, Static Nested Class and Inner Class are different. Static NESTED CLASS is an internal class that is declared as static (STATIC), which can not depend on external class instances being instantiated. And the usual internal classes need to be instantiated outside

Can institerate. 25. Dynamic INCLUDE Dynamic Include and Static Include in JSP? Dynamic incrude uses JSP: Include action to implement It always checks the changes in the file included, suitable for use

At the state page, and you can take parameters. Static include @ @ include file = "incrude.htm"%> 26, which is not included in the included file. Assertion is a commonly used commissioning in software development, and this mechanism is supported in many development languages. In the implementation, Assertion is a statement in the program.

It checks a Boolean expression, a correct program must ensure that this Boolean expression is true; if the value is false, the program is already in an incorrect shape.

At present, the system will give a warning or exit. In general, Assertion is used to ensure the most basic and key correctness of the program. Assertion checks are usually opened when developed and tested. In order to mention

High performance, after the software is released, the assertion check is usually closed. 27, what is GC? Why do you have GC? GC is a Gabage Collection, memory processing is where programmers are prone to problems, forget or wrong memory recycling will cause programs or systems.

Stable and even crash, the GC function provided by Java automatically monitors whether objects exceed the scope of the action to reach the automatic recycling memory, Java language does not provide release of allocated memory

Operation method. 28, Short S1 = 1; S1 = S1 1; What is wrong? Short S1 = 1; S1 = 1; What is wrong? SHORT S1 = 1; S1 = S1 1; (S1 1 calculation result is Int Type, need forced conversion type) Short S1 = 1; S1 = 1; (can be correctly compiled) 29, Math.Round (11.5) is equal to how much? Math.Round (11.5) = = 12Math.Round (-11.5) == - 11Round method Returns the length of the parameter closest, the parameter plus 1/2 is followed by its floor.30, string s = new string ("xyz"); created a few String Object? Two 31, design 4 threads, two threads increase 1 each time two, and the other two threads are reduced each time. Write the program. The following procedure uses internal classes to implement threads, and no order issues are not considered when J is reduced. Public class threadtest1 {private int j; public static void main (string args []) {threadtest1 tt = new threadtest1 (); incin = tt.new inc (); 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 RUN () {for (int i = 0; i <100; i ) {dec ();}}}} 32, have a reserved word in goto? Java, now not in Java Used. 33. Starting a thread is RUN () or start ()? Starting a thread is to call the start () method so that the virtual processor represented by the thread is running, which means it can be scheduled and executed by the JVM. This doesn't mean the thread

It will run immediately. The Run () method can generate a flag that must be exited to stop a thread. 34, EJB includes (sessionbean, entitybean) says their life cycle, and how to manage transactions? The lifecycle of the STASSIONBEAN: STATELESS session bean is determined by the container. When the client issues a request to establish a bean instance, the EJB container does not have to create a new bean instance for client call, but a place to find a present Some instances are provided to the client. When the client calls a Stateful session bean for the first time, the container must

You must immediately create a new bean instance in the server and associate onto the client. After this client calls the Stateful session bean method, the container assists the call to this.

The bean instance associated with the client. EntityBean: Entity Beans can survive relatively long time, and status is continuous. Entity Beans has always survive as long as the data in the database exists. Not press

Use applications or service processes. Even if the EJB container crashes, Entity Beans is also survived. The Entity Beans life cycle can be managed by the container or Beans. EJB Management Practice: Object Management Organization (OMG) Object (OTS), Sun Microsystems Transaction Service (JAVA), Java

Transaction API (JTA), XA interface of the development group (X / Open). 35. What are the application servers? BEA WebLogic Server, IBM WebSphere Application Server, Oracle9i Application Server, Jboss, Tomcat36, gives me a Runtime Exception you most often seen. ArithmeticException, ArrayStoreException, BufferoverflowException, BufferunderflowException, Cannotiexception,

CannotueException, ClassCastException, Cmmexception, ConcurrentModificationException, Domexception, EmptyStackException,

Illegalargumentexception, IllegalMonitorStateException, IllegalPathStateException, IllegalStateException, ImagingOpexception,

IndexOfboundsexception, MissingResourceException, NegativeArraysizeException, NosuchelementException,

NullPointersException, ProfileDataException, ProvideDataException, RasterFormatexception, SecurityException, SystemException, SYSTEMEXCEPTION

UndeclaredthrowableException, unmodifiableSetException, unsupportedOperationException37, whether the interface can inherit the interface? Does the abstract class can implement (IMPLEMENTS) interface? Does the abstract class can inherit the physical class (Concrete Class)? The interface can inherit the interface. Abstract classes can be implemented, whether abstract classes can inherit physical classes, but provided that the entity class must have a clear constructor. 38, List, SET, MAP inherits from the Collection interface? List, SET is not 39, how is the working mechanism of the data connection pool? J2EE server starts a certain number of pool connections, and maintain a lot Connects to this number of pools. When the client program needs to be connected, the pool driver returns an unused pool connection and exposes its expression as busy. If there is currently no idle connection, the pool driver has created a certain number of connections, and the number of new connections has configured parameters. When used in the pool connection

After using the completion, the pool driver is idle, and this connection can be used in other calls. 40. Is Abstract's Method can be static at the same time, whether it is Native at the same time, can you be synchronized? The array does not have Length () method, with the properties of the length. String has a length () method. 42, the elements in the set cannot be repeated, then what method is used to distinguish whether it is repeated? Is it == or equals ()? What is the difference between them? The elements in the set cannot be repeated, then use Iterator () The method is distinguished from whether it is repeated. Equals () is the judgment of whether two SETs are equal. Equals () and == Method Decide whether the reference value points to the same object Equals () override in the class, which is the true value of the content and type of two separate objects. 43. Whether the constructor can be ca not inherited by the Override® constructor constructor, so Overriding cannot be overridden, but it can be overloaded. 44, can you inherit the String class? The String class is that the final class cannot be inherited. 45. If SWTICH can act on Byte, whether it can act on long, whether it can work on SWITCH (expr1), EXPR1 is an integer expression. So the parameters passing to the switch and the case statement should be int, short, char or

Byte. Long, String can not work on SWTICH. 46, Try {} has a returnite, then the code in finally {} after this try is not executed, when is executed, before returnome or after it will be executed, execute before return. 47. Program: 2 Multiply 8 equal to a few? 2 << 348, two object values ​​(x.equals (y) == true (x.equals (y) == true), but there can be different Hash CODEs, This sentence is wrong? Is wrong, there is the same hash code. 49. 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. Object content

You can change in the called method, but the reference to the object will never change. 50. When a thread enters a synchronized method of an object, other methods of other threads can enter this object? No, one Synchronized method of an object can only be accessed by one thread. 51. Program: Write a Singleton. 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 state of static private, instantoneation, and GetInstance through a public Method

Take the reference to it, then call the method. Public class singleton {private singleton ()} // define one instance in itself, is it very strange? / Note This is private only for internal calling private static singleton instance = new singleton (); // here provides a static method for external access to this Class, you can directly access public static singleton getInstance () {return instance;}} The second form: public class singleleton {private static singleleton instance = null; public static synchronized singleton getInstance () {// This method is improved above, do not have to generate an object each time, only the first time // Generate an instance and improve efficiency! IF (instance == null) instance = new start;}} Other forms: Define a class, its constructor is private, all methods are static. It is generally considered that the first form is safer to be more securely 52, Java interface and the same or different degree of virtual classes 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. Inheritance

Compared to the interface has higher flexibility, there is no implementation code in the interface. When a class implements an interface, this class wants to implement all methods and properties in the interface, and in the interface

The properties of the surface are all public static below by default. All methods are public. A class can implement multiple interfaces. 53. 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 built into the Java class library

Semantic check. For example, the array subscript can trigger indexoutofboundsexception; nullpointerException will be triggered when accessing null objects. Another situation is Java allowed

The programmer expands this semantic check, and the programmer can create its own exception and free to choose when using the THROW keyword. All abnormalities are Java.lang.Thowable son

class. 54, 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 to solve the problem, which makes Java programmers when writing programs

Needless to consider memory management. 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. Garbage collectors are usually operated as a separate low-level thread, which is unpredictable to death.

Or do not use objects for clear and recycling, and programmers cannot collect garbage collectors in real time to garbage a target or all objects. Recycling mechanism has a replication

Garbage recovery and marking garbage collection, incremental garbage collection. 55. Please tell us how the thread you know is synchronized. 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 necessary to deepen a wait-to-state thread, but determined by JVM.

Which thread does not press priority. AllNotity (): Wake all threads in the waiting state, not to give all the locks of all awakening threads, but let them compete. 56. What are your collections you know? Main method? The most commonly used collections are LIST and MAP. The specific implementation of the List includes ArrayList and Vector, which are variable-sized lists, compared to build, storage, and operation

An element list of what 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. 57. Describe the principle mechanism of the JVM load Class file? The load in JVM is implemented by ClassLoader and its subclass, Java ClassLoader is an important Java runtime system component. It is responsible for finding and putting in runtime

Class of class files. 58. Can CHAR type variables can not store a Chinese Chinese character? Why? Can definition becoming a Chinese, because Java is encoded in Unicode, a char accounts for 16 bytes, so putting a Chinese is no problem 59, multi-thread There are several implementation methods, what is it? Synchronize several implementation methods, what is the multi-threaded implementation method, which inherits the Thread class and implementation of the implementation of the Runnable interface synchronization, Synchronized, WAIT and NOTIFY60, JSP built-in objects and methods. Request represents the HTTPSERVLETREQUEST object. It contains information about the browser request and provides several uses to get cookie, header, and session data.

Method. Response represents the HTTPSERVLETRESPONSE object and provides several methods for setting the response to the browser (such as cookies, header information, etc.) OUT objects are an instance of javax.jsp.jspwriter, and provide several ways to make you Used to return the output result to the browser. PageContext represents a javax.servlet.jsp.pageContext object. It is an API for convenient access to various range spaces, servlet related objects, and packages

Method for installing a universal servlet. Session represents a request Javax.Servlet.http.httpSession object. Session can store the user's status information Applicat represents a javax.servle.ServletContext object. This helps find information about the Servlet engine and the servlet environment represents a javax.servlet.servletConfig object. This object is used to access the initialization parameters of the servlet instance. Page Represents a servlet instance 61, the basic concept of the thread, the basic state of the thread, and the state of the thread refers to the execution unit of the program code, each program is at least in the program execution. A thread, that is, the program itself. There are four states in Java, respectively, running, ready, hang, and end. 62, JSP common directive <% @ page language = "java" contentYpe = "text / html; charset = GB2312" session = "true" buffer = "64kb" autoflush = "osthreadsafe =" TRUE "info =" TEXT "ErrorPage =" error.jsp "Iserrorpage =" true "iSelignored =" true "PageEncoding =" GB2312 "

Import = "java.sql. *"%> ISERRORPAGE (Can I use Exception object), iSelignored (是 表 表) <% @ include file = "filename"%> <% @ taglib prefix = "c" uri = " Http: // ... "%> 63, call doget () and dopost ()? The Method property in the FORM tag in the JSP page is called DOGET (), and dopost () is called for POST. 64. The lifecycle Web container loads servlet, and the lifecycle begins. The initialization of the servlet is performed by calling the servlet's init () method. Implementation by calling the service () method, according to the request

Methods of modifying different do *** (). End the service, the Web container calls the servlet's Destroy () method. 65. How do I have a single-thread mode of Servlet <% @ page isthreadsafe = "false"%> 66, the page interval object Request, Session, Application, Cookie, etc. What is the connection between? JSP is an extension of servlet technology, essentially a simple way of servlet, and emphasizes the application's appearance expression. After JSP compiles "class servlet". Servlet and JSP are the main difference

Point is that the application logic of the servlet is in the Java file and is completely separated from the HTML in the representation layer. The case of JSP is that Java and HTML can be combined into an extension .js

P file. JSP focuses on views, servlet is mainly used to control logic. 68. Four session tracking technology session scope servletsJSP page Description Page No is a representative object and attribute related to a page. A page is represented by a compiled Java Servlet class (which can have any include instructions, but no include action). This includes both servlets and JSP pages that are compiled into a servlet, is an object and attribute that represents a request issued to a web client. A request may span multiple pages, involving multiple web components (due to Forward fingers)

The relationship between the order and the includection is the object and attribute that represents a user experience with a web client. A web session can often span multiple clients to request Application is the object and attribute that represents the entire web application. This is essentially a full web application, including a number of pages, requests, and sessions.

Board scope 69, REQUEST object's main method: setttribute (String name, object): Sets the parameter value of Request (String Name): Returns GetAttributeNames (): Returns GetAttributeNames (): Return to Request Objects All attributes The name collection, the result is an example of an example getCookies (): Returns all Cookie objects of the client, the result is a cookie array getCharacterencoding (): Returns the character encoding method getContentLength (): Return the request for the length GetHeader ( String name): Get the file header information defined by the HTTP protocol: Returns all the values ​​of the request header of the specified name, the result is an instance of enumeration GetHeadernAmes (): Returns the name of the Request Header, the result is a piece Example GetInputStream (): Returns the requested input stream for obtaining the data getMethod (): getting the client to the server-side method getParameter (String Name): Get the client to send to the server side with Name specified Parameter Value getParameterNames (): Get the name of all parameters of the client to the server side, the result is a enumerated instance getParameterValues ​​(String name): Get all values ​​GetProtocol (): Get Client to Servers The protocol name GetQueryString (): get the query string getRequesturi (): Get the client address of the request string getRemoteAddr (): Get the client's IP address getRemotehost (): Get the client's name GetSession ([Boolean ]: Return and request related sessiongetServerName (): Get the name getServletPath (): Get the path of the script file requested by the client GetServerport (): Get the port number of the server Removeattribute (String Name): Delete one of the request Attribute 70, J2EE is a technical or platform or framework? J2EE itself is a standard, a standard platform provided for the development of a distributed application. J2EE is also a framework, including JDBC, JNDI, RMI, JMS, EJB, JTA and other technologies. 71. We often encounter some coded characters in the web application development process, such as ISO8859-1, etc., how to output a certain coded string? Public string translate (string str) {string tempstr = ""; try {tempstr = new string (Str.GetBytes ("ISO-8859-1"), "GBK"); Tempstr = Tempstr.trim ();} catch Exception e) {system.err.println (E.GetMessage ());} Return Tempstr;} 72, a brief description logic operation (&, ^) and conditional operation (&&, ||) distinguish.

Difference two points: a. Conditional operation can only be operated by Boolean, but logic operations can not only manipulate Boolean, but also operate value B. Logic operations do not generate short-circuit 73, how many forms of XML document definitions? What is the essence difference between them? What kind of way to parse XML documents? A: Two forms of DTD Schema, B: Nature difference: Schema itself is XML, can be parsed by XML parser (this is also the fundamental purpose of developing SCHEMA from DTD), C: There are DOMs, SAX, Stax, etc. DOM: processing It is very powerful in large files. This problem is caused by the tree structure of the DOM. This structure is more memory, and the DOM must be parsed.

Put the entire document into memory, suitable for random access to XML: Not present in Dom, SAX is an event-driven XML parsing method. It sequentially reads the XML file, and does not need to load all files all. When you encounter the beginning of the file, the end of the document, or standard

At the end of the label, it triggers an event, and the user handles the XML file by writing processing code in its callback event, and is suitable for the order of XML. Streaming API for XML (Stax) 74, briefly describe Synchronized and Java.util.concurrent.locks.lock is different? The main same point: Lock can complete all the features implemented by Synchronized, and there is more accurate thread semantics and better performance than synchronized. Synchronized will automatically release the lock, and Lock must request the programmer manual to release, and must

It must be released in the Finally clause. 75, EJB role and three objects A complete EJB-based distributed computing structure consists of six roles, which can be provided by different developers, and each role must follow Sun Company to provide SUN

EJB specification to ensure compatibility between each other. These six characters are EJB Components Developers (Enterprise Bean Provider), Applications Combinator (Application

Assembler, deployer, EJB server provider, EJB container provider (EJB Container Provider, system management

SYSTEM Administrator is a Remote (local) interface, home (localhome) interface, Bean class 76, EJB container provides service providing declaration cycle management, code generation, continuous management, security, transaction management, lock and And issue management and other services. 77. What are the prohibition of operations in EJB? 1. Unable to operate threads and threads API (thread API means non-threaded objects such as NOTIFY, WAIT, etc.), 2. Cannot operate AWT, 3. Can't implement server function, 4. Cannot be born for static

Access, 5. You cannot use the IO operation to access the file system, 6. You cannot load the local library. 78. The REMOTE interface and the home interface main REMOTE interface defines the business method for the EJB client calling business method. The HOME interface is an EJB factory for creating and removing the EJB instance 79. The lifecycle of the bean instance is a buffer pool management for the Stateless session bean, the Entity Bean, and the Entity Bean and Statefull Session Bean.

There is a cache management, typically contains the creation instance, set the context, create an EJB Object (CREATE), business method call, Remove, etc. For the bean where the buffer pool management, the instance is not removed from memory, but the buffer pool The scheduling mechanism continues to reuse the instance, and the bean for the presence of Cache management is maintained by activation and deactivation mechanisms.

State and limit the number of instances in memory. 80, EJB activation mechanism is taken as an example: its cache size determines the number of bean instances that can exist in the memory, according to the MRU or NRU algorithm, instance is activated and deactivated.

When the state is migrated, the activation mechanism is when the client calls an EJB instance business method, if the corresponding EJB Object is found to have a BEAN instance that does not bind the corresponding bean storage

This instance is replied to (activation) in (activation) by serialization mechanism. The corresponding EJBACTIVE and EJBPASSIVATE methods are called before the state change. 81. Several type sessions of EJB (session) bean, entity (Entity) bean-driven ("STATEFUL) and stateless (stateless) two entity beans can be divided into BEAN management persistence (BMP) and contufficient persistence (CMP) of container management (CMP) 82, customer service end calling several basic steps for EJB object Setting JNDI Services Factory and JNDI Service Address System Properties, lookup Home interface, call from Home Interface CREATE method Creates a Remote interface, calling its business via the Remote interface

method. 83. How to specify the size of the size of the size of WebLogic? In the Script of WebLogic (STARTSERVERNAME in the Domian corresponding server directory), add SET MEM_ARGS = -XMS32M -XMX200M, which can be adjusted the most

Small memory is 32M, the maximum 200m84, how to set WebLogic hot start mode (development mode) and product release mode? You can modify the startup mode of the corresponding server in the management console as one of the development or product modes. Or modify the service startup file or Commenv file, add set

Production_Mode = true. 85. Do you need to enter a username and password when starting? Modify the service startup file, add WLS_USER and WLS_PW items. You can also add an encrypted username and password in the boot.properties file. 86, after the WebLogic Management Table, a application domain (or a website, domain) is configured after configuring information about the JMS and EJB or connection pools, What file is actually saved? Save in this Domain's config.xml file, it is the core configuration file of the server. 87. Talk about the default directory structure of a Domain in WebLogic? For example, put a simple helloworld.jsp into the point of directory, but you can enter the http: // host on the browser:

The slogan //helloword.jsp can see the running result? For example, this is used here to write JavaBean how to do? Domain Directory / Server Directory / Applications, place the application directory in this directory will be used as an application access If it is a web application, the application directory needs to meet the web application directory requirements.

JSP files can be placed directly in the application directory, JavaBean needs to be placed in the CLASSES directory of the web-INF directory of the application directory, setting the server's default application will be available on the browser without entering the application name. 88. What configuration files need to be involved in the WEBLOGIC?

The configuration files involved in different types of EJBs are different, and the configuration files involved include EJB-JAR.XML, WebLogic-EJB-JAR.XMLCMP entity beans generally need WebLogic-CMP-RDBM

S-JAR.XML 89, how to use DemoIdentity.jks and Demotrust.jks KeyStore to implement SSL in WebLogic authentication configuration or J2EE (standard) for SSL configuration default installation, using demoidentity.jks and demotrust.jks KeyStore to implement SSL, need to configure server usage ENABLE SSL, configure its port, need to product mode

To get a private key and a digital certificate from CA, create an Identity and Trust KeyStore, load the key and a digital certificate. You can configure this SSL connection to one-way or two-way. 90, how to view EJBs that have been released in WebLogic? You can use the management console, you can view all published EJB91 in its deployment, what is the use? CORBA standard is a public object request agency structure (Common Object) Request Broker Architecture, Managing Organization (Object Management Group, Return

Write as OMG) Standardization. Its composition is the interface definition language (IDL), language binding (binding: also translated into a cable) and an agreement to interoperate interoperability. Its purpose is: use different processes

The order design language is written in different processes, and is developed for different operating systems. 92, talk about several common modes in J2EE you are familiar with or have heard? Some views of the design pattern session facade pattern: Use sessionBean to access EntityBean Message Facade Pattern: Implement asynchronous call EJB Command Pattern: Use Command JavaBeans to replace SessionBean, a lightweight access Data Transfer object factory: Simplified ENTITITYBEAN Data Provision for ENTITYEBEAN Data: Simplified ENTITYBEAN Data Provision for ENTITITYBEAN Data Features Business Interface: The same interface specification business logic is implemented by remote (local) interface and Bean class Consistency EJB architecture design quality will directly affect the performance, scalability, maintainability, components reusability and development efficiency. The more complex the project, the more the project team is, the more it can be reflected

The importance of good design. 93. Talking about the MDB of the Persistent and Non-Persisten's Differential Persistent mode when developing message beans in WebLogic can guarantee the reliability of messaging, that is, if the EJB container has problems and the JMS server will still use the message in this MDB. When it is sent,

The message of the Non-persistent method will be discarded. 94. What kind of method is generally implemented when the servlet is executed? public void init (ServletConfig config) public ServletConfig getServletConfig () public String getServletInfo () public void service (ServletRequest request, ServletResponse response) public void destroy () 95, j2ee common design patterns? Description plant mode. 23 design patterns in Java: Factory, Builder, FactoryMethod, Prototype, Singleton, Facade, Adapter ( Adapter mode), Bridge (Bridge mode), Composite, Decorator, Flyweight, Proxy, Command, Interpreter, Visitor (Interpreter Mode), Visitor Visitor Mode CHAIN ​​OF RESPONSIBLEITY Factory mode: Factory mode is a model that is often used, and the class implemented according to the factory mode can generate an instance of a class in a set of classes according to the provided data, usually this The group has a common abstract parent class and implements the same method, but these methods have different operations for different data. First, you need to define a base class, which is different from

The method implements the method in the base class. Then need to define a factory class, and the factory class can generate different subclass examples depending on the conditions. When a sub-class is obtained, the developer can call

The method in the base class does not have to consider the example of which subclass is returned. 96, EJB needs to implement its business interface or home interface, please briefly describe the reasons. The remote interface and home interface do not need to be directly implemented, and their implementation code is generated by the server, and the implementation class in the program run is used as an instance of the corresponding interface type. 97, what kinds of methods are there? Please list it. Implement a rapid sort with Java. Sort by: Insert Sort (Direct Insert, Hill Sort), Switching Sort (Bubble Sort, Rapid Sort), Select Sort (Direct Selection Sort, Stack Sort), Multiple Sort, Distribution Sort (Sort, Base Sort ) Quickly sorted pseudo code. / / Use a quick sort method to select an element from a [0: N- 1] from a [0: N- 1] as a middle, which is divided into two segments of LEFT and Right, making left The elements in the middle are equal to the fulcrum, and the elements in Right are greater than the rapid sorting method to reciprocally use the fast sorting method to use the fast sort method to use the fast sorting method to use the fast sorting method for LEFT MIDDLE RIGHT98, please The noun commonly used in J2EE is explained (or briefly description) Web container: The application component (JSP, servlet) is provided with an environment, so that JSP, servlet interacts directly in the environment variable interface in the container, and does not have to pay attention to other

system problem. There is mainly a web server to achieve. For example: Tomcat, WebLogic, WebSphere, etc. The interface provided by the container strictly abides by the Web Application Standard in the J2EE specification

. We call the Web Server of the above standards called the web container in J2EE. EJB container: Enterprise Java Bean container. More industry segments. He provides various management functions that run the component EJB. Just meet the J2EE specification EJB

Enclose the container, it will be managed by the container immediately. And you can obtain system level services through ready-made interfaces. For example, email services, transaction management. JNDI: (Java Naming & Directory Interface) Java Name Directory Service. The main features are: provide a directory system that allows applications from all over the world to

Leave your own index to meet the functionality of fast finding and positioning distributed applications. JMS: (Java Message Service) Java Message Service. It mainly implements communication between the various applications. Includes point-to-point and broadcast. JTA: (Java Transaction API) Java Transaction Services. Provide a variety of distributed transaction services. The application only needs to call the interface provided. JAF: (Java Action Framework) Java Security Authentication Framework. Provide some security control frames. Let developers achieve their own personal security through a variety of deployment and customization

Full control strategy. RMI / IIOP: (Remote Method Invocation / Internet Object Request a Intermediary Protocol) They are primarily used to serve through remote calls. For example, there is a computer running on a computer.

A program that provides stock analysis services, we can implement them directly on the local computer. Of course, this is to communicate between heterogeneous systems through a certain specification. R

Mi is a Java unique. 99. How do Java languages ​​for exceptions, keywords: throws, throw, try, catch, finally represents what significance? Can I throw an exception in the TRY block? Java processes abnormally by object-oriented methods, and classifies a variety of different exceptions and provides a good interface. In Java, every exception is an object, it is throwab

Examples of LE class or other subclasses. When a method has an abnormality, an exception object is thrown, and the object contains abnormal information, and the method of calling this object can capture this exception.

Treatment. Java's exception handling is achieved by 5 keywords: try, catch, throw, throws and finally. In general, use TRY to perform a program, if

It is currently an exception, and the system will throw an exception. At this time you can capture (CATCH) through its type, or finally by the default processor. Use TRY to specify a program that prevents all "exceptions". Keeping followed by the Try program, a Catch clause should be included to specify the type of "exception" you want to capture. The throw statement is used to clearly throw an "exception". Throws is used to indicate a variety of "exceptions" that may be thrown by a member function. Finally is executed to ensure that "exception" occurs regardless of the code. You can write a TRY statement outside in a member function call, write another TRY statement to protect other code inside this member function. Whenever you encounter a TRY statement, "Abnormal" framework

Put it on the stack until all TRY sentences are completed. If the TRY statement of the next level does not process some "exception", the stack will be expanded until the Trich Treated Terrand Tricks

RY statement. 100, a ".java" source file can include multiple classes (not internal classes)? What is the limit? Yes. There must be only one class name with the file name. 101. All parts of the MVC have those technologies to achieve? How to achieve? MVC is a short written by Model-View-Controller. "Model" represents the application's business logic (implemented through javabean, EJB component), "view" is the application's indication (

Produced by JSP pages), "controller" is a process control (generally a servlet) that provides applications, which makes application logic, processing procedures, and display logic through this design model.

Different components. These components can interact and reuse. 102. How many ways to implement one thread in Java? What is the use of keyword modified synchronization methods? Stop () and SUSPEND () methods do not recommend it? There are two implementation methods, which are inheriting the Thread class and implementing the runnable interface with the synchronized keyword modification synchronization method against the use of STOP () because it is not safe. It will release all locks acquired by the thread, and if the object is in a non-connected state, then other threads can check in that state.

And modify them. It is difficult to check the real problem. The suspend () method is prone to dead locks. When calling suspend (), the target thread will stop, but it is still held here.

Previously obtained the lock. At this point, any other thread cannot access the locked resource unless the thread is restored to the thread. For any thread, if they want to resume the target thread, it will cause a deadlock to use any lock resources. So you should not use suspend (), but you should place a sign in your own Thread class, pointing out the thread should be active.

Still hang. If the flag indicates that the thread should hang, use Wait () to enter the waiting state. If the flag indicates that the thread should be restored, use a Notify () to restart the thread. 103. There are several types of streams in Java? JDK provides some abstract classes for each type of stream for inheritance, please say which classes are they? Byte stream, character stream. Byte streams are inherited in InputStream / OutputStream, and the character stream is inherited in InputStreamWriter. In java.io bag

There are many other streams, mainly to improve performance and convenience. 104. Does memory leaks in Java? Please briefly describe it. meeting. Such as: INT I, I2; RETURN (I-I2); // when i is a positive number, i2 is a large negative number. The result will cause a seating, resulting in errors. 105. What is the mechanism for achieving polymorphism in Java?

The method of rewriting Overriding and overloading overloading is a different manifestation of Java polymorphism. Override Overriding is a manifestation of polymorphism between the parent class and the subclass, overloading overloading

Is a manifestation of a class in a class. 106. What is the basic principle of the garbage collector? Can garbage collectors recycle memory immediately? Is there any way to actively notify the virtual machine for garbage collection? For GC, when the programmer creates an object, the GC starts to monitor the address, size, and usage of this object. Typically, GC uses a map-like manner (HEAP)

All objects in. In this way, it is determined which object is "can be reached", which object is "unreachable". When the GC determines that some objects are "unreachable", GC is responsible for recycling these memory.

space. can. The programmer can manually execute System.gc (), inform GC operation, but Java language specification does not guarantee that GC will be executed. 107, difference between static variables and instance variables? Static i = 10; // constant class a a; a.i = 10; // variable 108, what is Java serialization, how to implement Java serialization? Serialization is a mechanism for processing the target stream, the so-called object stream is to fluidize the contents of the object. You can read and write the fluidized object, or the flow

Objects are transmitted between the network. Serialization is to solve problems caused by read and write operations on object flows. Realization of serialization: The sequenceful class is required to implement the serializable interface. The interface does not need to implement the method. Implements serializable is just to mark the object.

Seried, then use an output stream (such as: fileoutputstream) to construct an ObjectOutputStream object, then use ObjectOutputStream pair

The WriteObject (Object Obj) method of the like can write the objects of the parameter (ie, save its status), and if you want to recover, you can use the input stream. 109. Can I send a call to a non-Static method from one STIC method? No, if it contains the object's method (); does not guarantee the initialization of the object. 110, when writing the clone () method, what is the code, what is it? Clone has default behaviors, super.clone (); he is responsible for generating the right size space and copying in position. 111, in Java, how to jump out the current multiple nesting loop? Use Break; Return method. 112, List, MAP, SET three interfaces, how are you with an alternative? List holds an element in a specific order, there can be repeated elements. SET cannot have a repeating element, internally sorted. Map saves the key-value value, Value can be more values. 113, what is J2EE? J2EE is a multi-dimensional, distributed, distributed, distributed, component-based, based on the component (Component-Base). In such an application system, it can be divided into Different components, these components can be on different computers and in the corresponding level (tier)

. The hierarchies are included in the ClientN Tier components, web layers, and components, Business layers, and components, and corporate information systems (EIS) layers. 114, UML standard modeling language UML. Modal example, static map (including class diagram, object map, and package), behavioral diagram, interaction map (sequential diagram, cooperation graph), implementation diagram. 115. Some commonly used classes, bags, interfaces, please give 5 commonly used classes: BufferedReader BufferedWriter FileReader Filewirter String Integer Common Package: Java.lang Java.awt Java.io Java.util Java.sql common interface : Remote List Map Document NodeList 116, the development is used in the development model? What is used? Each mode describes a question in our environment and then describes the core of the solution. In this way, you can use those

Existing solutions do not need to work on the same job. Mainly used in the design pattern of MVC. Used to develop JSP / Servlet or J2EE related applications. Simple factory model, etc. 117, what actions do you have? What is the role? JSP has the following six basic action JSP: include: Introducts a file when the page is requested. JSP: Usebean: Find or instantiate a JavaBean.

JSP: setProperty: Sets the properties of JavaBean. JSP: getProperty: Outputs the properties of a JavaBean. JSP: Forward: Turn the request to a new page.

JSP: Plugin: Generate Object or Embed tags based on the browser type. 118, anonymous inner class (anonymous internal class) can be extends other classes, can IMPLEMENTS INTERFACE (interface)? Can inherit other classes or complete other interfaces, which are commonly used in Swing program. 119. Differences between application servers and Web Server? Application Server: WebLogic, Tomcat, JBoss Web Server: IIS, Apache120, BS and CS connection and difference. C / S is the abbreviation of Client / Server. Servers typically use high-performance PCs, workstations, or small machines, and use large database systems such as Oracle, Sybase, Informix, or SQL Server. The client needs to install a dedicated client software. B / S is the abbreviation of brower / server, just install a browser (Browser) on the client, such as Netscape Navigator or Internet

Explorer, server installs Oracle, Sybase, Informix, or SQL Server and other databases. Under this structure, the user interface is fully implemented through the WWW browser, one of the transaction

The series is implemented at the front end, but the main transaction logic is implemented on the server. The browser interacts with the database with the database. C / S and B / S distinct: 1). Different hardware environments: C / S is typically established on a dedicated network, a small network environment, and the local area network will then provide connection and data exchange services through a dedicated server. B / S is built on the wide area network, does not have to be special Network hardware environment, examples of online Internet access, rent equipment. Information yourself management. There is a stronger adaptation range than C / S, generally

Operating system and browser will line 2). Different C / S are generally facing relatively fixed user bases for security requirements, which is very controlled for information security. General highly confidential information systems use C / S structures suitable. Can be publicly available via B / S distribution

Information. B / S is built on wide area network, which is relatively weak, and may facing unknown users. 3). Different C / S procedures for program architectures can be more payable, multi-level values ​​can be verified for permissions. The system runs can be less considered. B / S is a multi-consideration of security and access speed, based on the basis for more optimization Above it. Programming architecture with a higher requirements of C / S is the trend of development, from MS

BizTalk 2000 Exchange 2000 et al., The system, etc., fully supported network components. Sun and IBM push JavaBean component techniques, etc., make B / S mature more. 4). Software reuses different C / S programs can inevitably considers, the reuse of components is not as low as reuse of components under B / S, and the multi-structure of B / S pairs, requires relatively independent functions of components. It is better to reuse. If you buy a table, you can use it, not the stone table 5 on the wall. System Maintenance Different C / S procedures Due to overall, the overall investigation, the problem and system upgrade. Upgrade is difficult. Maybe a new system B / S component composition, aspect component individual replacement, implementation system Sewing upgrade. System maintenance overhead is minimized. User downloads and installations from the Internet can be upgraded. 6). Different C / S procedures can handle user plane fixation, and high demand in the same area, security requirements, related to the operating system. It should be the same system B / S is built on wide-area network, facing different user groups, dispersing the region This is C / S that cannot be made. It is the smallest relationship with the operating system platform. 7). Different user interfaces are mostly established WINDOW platforms, the performance method is limited, and the programmer is universally required to establish a higher B / S on the browser, there is a richer and vivid manifestation and user communication. And most difficulty Reduce, reduce development costs. 8). Different information flows Different C / S procedures are generally a typical centralized mechanical treatment, and the relatively low interactive is relatively low. The flow direction of B-B B-C B-G, and the flow direction changes, more like the trading center. 121, Linux under the thread, the explanation of the GDI class. Linux implemented is based on the "one-to-one" thread model of the core lightweight process, and a thread entity corresponds to a core lightweight process, and the management between the thread is implemented in the nuclear external function library. The GDI class is an image device programming interface class library. 122, Struts Applications (such as Struts Architecture) Struts is a Framework for developing the open source of the web application using Java Servlet / JavaServer Pages technology.

The Struts can develop an application architecture based on MODEL-View-Controller design mode. Struts has the following main functions: 1. Contains a Controller Servlet,

Can send the user's request to the corresponding Action object. II.Jsp Free TAG library, and provide association support in the Controller Servlet to help developers create interactive form applications

. 3. Provide a series of practical objects: XML processing, automatically handle JavaBeans properties, international tips and messages through Java Reflection APIs. 123, JDO is what JDO is a new specification for Java objects, which is a referred to as Java Data Object, and is also a standardized API for accessing objects in a data warehouse. JDO provides transparent

Object storage, therefore for developers, storage data objects do not require additional code (such as JDBC API). These cumbersome routines have been transferred to JDO product providers

On the body, the developers will be freed out to concentrate on time and energy logically logically. In addition, JDO is flexible because it can run on any data underlayer. JDBC is just a relationship

According to the library (RDBMS) JDO is more common, providing storage capabilities of any data underlying, such as relational database, file, XML, and object database (ODBMS), etc., make it applying portability

Strong. 124, can the internal class can reference the membership of the class? Is there any restriction? An internal class object can access the content 125 of the created external class object, the web service noun explanation. JSWDL development package. JAXP, JAXM explanation. SOAP, UDDI, WSDL Explanation. Web ServiceWeb Service is a network-based, distributed modular component, which performs specific tasks, complies with specific technical specifications, which make Web Service interoperate with other compatible components. JAXP (Java API for XML PARSING) Defines the universal interface using DOM, SAX, XSLT in Java. This way in your program you only use these universal interfaces, when you need

You don't need to modify the code when you change the specific implementation. JAXM (Java API for XML Messaging is an API that provides access methods and transport mechanics for SOAP communication. WSDL is an XML format for describing network services as a set of endpoints that operate on messages that contain document information or process information. This format is first

Abstract descriptions and messages then bind them to specific network protocols and message formats to define endpoints. The relevant specific endpoints are combined into an abstract endpoint (service). SOAP is a Simple Object Access Protocol, which is a lightweight protocol used to exchange XML encoded information. The purpose of UDDI is to establish standards for e-commerce; UDDI is a web-based, distributed, implementation standard specification for information registry provided by Web Service, and also includes one

The composition allows companies to register their own Web Service to make the implementation criteria for access protocols that others can discover.

Java code check error 1.Abstract class name {private string name; public abstract boolean isstupidName (String name) {}} heroes, what is wrong? Answer: wrong. Abstract Method must end with a semicolon and do not bring a curly bracket. 2.PUBLIC CLASS Something {Void Dosomething () {private string s = ""; int L = s.Length ();}} Is it wrong? Answer: wrong. Any access modifier (private, PUBLIC, and Protected) cannot be placed before the local variable. Final can be used to modify local variables (Final is like Abstract and Strictfp, all non-access modifiers, Strictfp can only modify Class and Method rather than variable). 3.Abstract class something {private abstract string Dosomething ();} This seems to have nothing wrong? Answer:

wrong. Abstract Methods cannot be modified in private. Abstract Methods is the specific details of the subclass item, how can I use Private to block AbstractMethod? (Simply, you can't add Final before Abstract Method). 4.public class something {public int address (femal int x) {return x;}} This is more obvious. Answer: wrong. INT X is modified to Final, meaning X cannot be modified in Addone Method. 5.public class something {public static void main (String [] args) {other o = new other (); new thing (); public void addone (Final Other O) {O.}; } Class Other {public Int i;} is very similar to the above, is about Final's problem, is this wrong? answer: Correct. In Addone Method, the parameter O is modified into final. If we modified O's Reference in Addone Method (for example: o = new other ();), then this question is also wrong. But this is modified here that the MEMBER VAIRABLE (member variable) of O, while the REFERENCE does not change. 6.Class Something {Int i; public void dosomething () {system.out.println ("i =" i);}} Is there anything wrong? Can't see it. Answer: Correct. The output is "i = 0". INT i belongs to Instant Variable (instance variable, or a member variable). Instant variable has DefaultValue. INT's default value is 0.7.class something {final int i; public void dosomething () {system.out.println ("i =" i);}}} and topical only one place is different, that is, more A final. Is this wrong? Answer: wrong. Final INT i is a Final's Instant Variable (instance variable, or a member variable). Final Instant Variable No default

Value must be given a clear value before the constructor ends. Can be modified to "Final INT I = 0;". 8.public class something {public static void main (String [] args) {something s = new something (); system.out.println ("s.dosomething () returns" DOSMETHING ());} public string dosomething ) {Return "Do Something ...";}} It looks perfect. Answer: wrong. It seems that there is no problem in main dosomething in main, after all, two Methods are in the same class. But look carefully, main is static. Static

Method can't directly call Non-Static Methods. Can be changed "System.out.Println (" s.dosomething () Returns "

S.DOSMETHING ()); ". Similarly, Static Method cannot access Non-Static Instant Variable.9. Here, the file name of the Something class is OthersHing.Javaclass Something {private static void main (String [] Something_to_do) {system .out.println ("Do Something ...");}} This seems to be obvious. Answer: Correct. Never said that Java's Class name must be the same as its file name. But the name of the public class must be named The same .10.10.interface a {int x = 0;} class b {int x = 1;} Class C Extends B Implements A {public void px () {system.out.println (x);} public static void main String [] args) {new c (). Px ();}} answer: error. Errors occur when compiling (Error Description Different JVMs have different information, means that the unclear X call, two X Match (just like import java.util

Declaring Date directly with java.sql two packages). For the variable of the parent class, you can use super.x to explicit, and the attribute of the interface is implied as public static final. So you can

Clear by A.x. 11.interface Playable {void play ();} interface Bounceable {void play ();} interface Rollable extends Playable, Bounceable {Ball ball = new Ball ( "PingPang");} class Ball implements Rollable {private String name; public String GetName () {return name;} public ball (String name) {this.name = name;} public void play () {ball = new ball ("football"); system.out.println (ball.getname ()) This error is not easy to find. Answer: wrong. "Interface Rollable Extends Playable,

Bounceable "No problem. Inherface can inherit multiple interfaces, so it is right. The problem is in Interface Rollable" ball ball = new

Ball ("pingpang"); "An Interface Variable (interface variable, or member variable) declared in Interface, the default is public static final. That is to say

"Ball ball = new ball (" pingpang ");" actually is "public static final ball ball = new

Ball ("pingpang"); "In the Play () method of the Ball class," football ");" changed the Ball Reference, and the Ball from RollableInterface, the ball in Rollable Interface is Public static final, final's Object is not to be changed. Therefore, the compiler will be "Ball = New

Ball ("Football"); "This is displayed here.

Java program 1. Now enter N numbers, separately, separate; then select liter or descending order, press what order is displayed on another page, and the result is RESETIMPORT JAVA.UTIL. *; Public Class Bycomma {public static String [] splitstringBYCOMMA (String Source) {if (source == null || source.trim (). Equals (")) Return Null; StringTokenizer Commatoker = New StringTokenizer (Source,", "); String [] Result = New String [commatoker.counttokens ()]; int i = 0; while (commatoker.hasmoretoKens ()) {result [i] = commatoker.nextToken (); i ;} return result;} public static void main (String args [] ) {String [] s = splitstringBYCOMMA ("5, 8, 7, 4, 3, 9, 1"); int [] ii = new int [S.LENGTH]; for (int i = 0; i = 0; i -) {system.out.println (II [i]);}} }2. The amount converted, the amount of the Arab figures converted into Chinese traditional forms such as (¥ 1011) -> (1 thousand and one yuan) output.

package test.format; import java.text.NumberFormat; import java.util.HashMap; public class SimpleMoneyFormat {public static final String EMPTY = ""; public static final String ZERO = "zero"; public static final String ONE = "One "; Public static final string tW =" "; public static final string three =" 叁 "; public static final string four =" "; public static final string file =" Wu "; public static final string Six =" land "; Public static final string seven =" 柒 "; public static final string eight =" 捌 "; public static final string nine =" 玖 "; public static final string ten =" Pick up "; public static final string hundred =" 佰"; public static final String tHOUSAND =" thousand "; public static final String TEN_THOUSAND =" Wan "; public static final String HUNDRED_MILLION =" one hundred million "; public static final String yUAN =" meta "; public static final String JIAO =" angle "; Public static final string fen =" division "; public static final string dot =". "; Private static simplemoneyformat formatter = null; private hashmap ch INESENUMBERMAP = New hashmap (); private hashmap chinesemoneyPattern = new hashmap (); private numberformat Numberformat = Numberformat.getInstance ();

Private SimpleMoneyformat () {Numberformat.SetMaximumFracthenDigits (4); Numberformat.SetMinimumfractionDigits (2); NumberFormat.SetGroupingUsesed (false);

ChineseUmbermap.put ("0", zero); chinesenumbermap.put ("1", one); chinesenumbermap.put ("2", two); chinesenumbermap.put ("3", three); chinesenumbermap.put ("4 ", Four); chinesenumbermap.put (" 5 ", FIVE); chineseumbermap.put (" 6 ", six); chinesenumbermap.put (" 7 ", seven); chinesenumbermap.put (" 8 ", eight); chinesenumbermap .put ("9", nine); chinesenumbermap.put (dot, dot); ChineseMoneyPattern.put ("1", ten); chinesemoneyPattern.put ("2", hundred); chinesemoneyPattern.put ("3", Thousand CHINESEMONEYPATTERN.PUT ("4", Ten_thousand; ChineseMoneyPattern.put ("5", TEN); chinesemoneyPattern.put ("6", hundred); chinesemoneyPattern.put ("7", thousand); chinesemoneyPattern.put "8", hundred_million;

Public static simpleMoneyformat getInstance () {if (formatter == null) formatter = new SimpleMoneyFormat (); Return Formatter;

Public String Format (String MoneyStr); string result; result = convertTochineseNumber (MoneyStr); result = addunitstochineseMoneyString (result); Return Result;}

Public String Format (Double Moneydouble) {Return Format (NumberFormat (Moneydouble));

Public String Format (INT Moneyint) {Return Format (NumberFormat (Moneyint));

Public String Format (Long Money) {Return Format (Numberformat.Format (Money));

Public String Format (Number Moneynum) {Return Format (Numberformat.Format (MoneyNum));

private String convertToChineseNumber (String moneyStr) {String result; StringBuffer cMoneyStringBuffer = new StringBuffer (); for (int i = 0; i 0; I -) {cmoneyStringBuffer.insert (i, chinesemoneypattern.get (Empty MoneyPatterncursor); MoneyPatterNCursor = MoneyPatterncursor == 8? 1: Moneypatterncursor 1;}

String fractionPart = cMoneyStringBuffer.substring (cMoneyStringBuffer.indexOf () "."); CMoneyStringBuffer.delete (cMoneyStringBuffer.indexOf (), cMoneyStringBuffer.length () ".");! While (cMoneyStringBuffer.indexOf ( "zero-pick") = -1) {cmoneyStringBuffer.Replace (CmoneyStringBuffer.indexof ("Zero Pick"), cmoneyStringBuffer.indexof ("Zero Pick") 2, ZERO);} While (cmoneyStringBuffer.indexof ("Zero")! = -1) {cMoneyStringBuffer.replace (cMoneyStringBuffer.indexOf ( "zero Bai"), cMoneyStringBuffer.indexOf ( "zero Bai") 2, zERO);} (! cMoneyStringBuffer.indexOf ( "zero thousand") = -1) while {cMoneyStringBuffer. replace (cMoneyStringBuffer.indexOf ( "zero thousand"), cMoneyStringBuffer.indexOf ( "zero thousand") 2, zERO);} while (! cMoneyStringBuffer.indexOf ( "zero Wan") = -1) {cMoneyStringBuffer.replace (cMoneyStringBuffer .indexof ("万"), cmoneyStringBuffer.indexof ("万") 2, Ten_thousand);} while (cmoney ")! = -1) {cmoneyStringBuffer.Replace (cmoneyStringBuffer.indexof "亿"), cmoneyStringBuffer.indexo f ("零") 2, hundred_million;} while (cmoney "! = -1) {cmoneyStringBuffer.Replace (CmoneyStringBuffer.indexof (" zero zero), cmoneyStringBuffer.indexof (" dated ") 2, ZERO);} if (cMoneyStringBuffer.lastIndexOf (ZERO) == cMoneyStringBuffer.length () - 1) cMoneyStringBuffer.delete (cMoneyStringBuffer.length () - 1, cMoneyStringBuffer.length ()); cMoneyStringBuffer. Append (FRActionPAR);

Result = cmoneyStringBuffer.tostring (); return result;}

private String addUnitsToChineseMoneyString (String moneyStr) {String result; StringBuffer cMoneyStringBuffer = new StringBuffer (moneyStr); int indexOfDot = cMoneyStringBuffer.indexOf (DOT); cMoneyStringBuffer.replace (indexOfDot, indexOfDot 1, YUAN);} END

转载请注明原文地址:https://www.9cbs.com/read-48846.html

New Post(0)