Java interview questions

xiaoxiao2021-03-14  187

Basic knowledge: Simple principle and application of exception handling mechanism in C or Java. When the Java program violates the semantic rules of Java, the Java virtual machine will represent an error as an exception. Violation of semantic rules include 2 cases. One is a semantic check in the Java class library. For example, the array subscript can trigger indexoutofboundsexception; nullpointerException will be triggered when accessing null objects. Another situation is that Java allows programmers to extend this semantic check, and programmers can create their own exceptions and freely choose to trigger exceptions with throw keywords. All exceptions are subclasses of java.lang.thowable. 2. The same and different sages of Java interfaces and C virtual classes. Since Java does not support multi-inheritance, it is possible to use a class or object to use a method or attribute in several classes or objects, and existing single inheritance mechanisms cannot meet the requirements. Compared to inheritance, the interface has higher flexibility because there is no implementation code in the interface. When a class implements an interface, this class is to implement all methods and properties in the interface, and the properties in the interface are all public static below, all methods are public. Public. A class can implement multiple interfaces. 3. Advantages and principles of garbage collection. And consider 2 recycling mechanisms. A significant feature in the Java language is to introduce the garbage collection mechanism, which makes the problem of the most headache of C programmers, making the Java programmers no longer need to consider memory management when writing programs. Since there is a garbage collection mechanism, the object in Java no longer has the concept of "scope", and only the reference to the object has a "scope". Garbage recycling can effectively prevent memory leaks, effective use of memory that can be used. The garbage collector is usually operated as a separate low-level thread. In the case of unpredictable objects that have been died or have not used for a long time for a long time for a long time, the programmer cannot call the garbage collector in real time. Object or all objects are garbage collection. The recycling mechanism has a replica collection of garbage collection and marking garbage recovery, incremental garbage recovery. 4. Please tell the thread synchronization you know. Wait (): Make a thread in the waiting state and release the LOCK of the object held. Sleep (): Make a running thread in sleep state, is a static method, call this method to capture InterruptedException exceptions. NOTIFY (): Wake up a thread in a waiting state, note that when this method is called, it is not exactly the thread that is awakened, but is determined by the JVM which thread is awake, and is not pressed. AllNotity (): Wake all threads in the waiting state, not to give all the locks of all awakening threads, but let them compete. 5. Please talk about the usage and function of the system and virtual functions. 6. What is the difference between ERROR and EXCEPTION? Error indicates that the system-level error and the exception do not have to be processed, and Exception represents an exception to capture or require a program. 7. A class in Java is declared as a final type, what does it mean? It is said that the class cannot be inherited, it is a top class. 8. Describe your most common programming style. 9. 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. Piles are a set element 10. If the system wants to use a large integer (more than the long range), you design a data structure to store such a super-large number and design a algorithm to achieve a large integer addition.

Public class bigint () {int [] arrone = new arrone [1000]; string = ""; public int [] arr (string s) {IntString = s; for (int i = 0; I

16, the difference between Collection and Collectes. Collections is a class under java.util that contains a variety of static methods related to the collection. Collection is an interface under java.util, which is a parent interface of a variety of collections. 17. When did you use Assert. As an assertion, a statement containing Boolean expression, assuming that the expression is TRUE when this statement is executed. If the expression is calculated as false, then the system will report an AssertionError. It is used to debug purposes: assert (a> 0); // throws an assertionError if a <= 0 assertion can have two forms: assert expression1; assert expression1: expness2; Expression1 should always generate a Boolean value. Expression2 can be any expression that draws a value. This value is used to generate a String message displaying more debugging information. As default, it is disabled by default. To enable assertions while compiling, you need to use Source 1.4 tag: Javac -Source 1.4 Test.java To enable assertion at runtime, you can use the -enableassertions or -ea tag. To disable assertion at runtime, you can use the -DA or the -disableAssertions tag. To enable assertion in the system class, you can use the -esa or -dsa tag. You can also enable or disable assertions on the basis of the package. An assertion can be placed at any position that is not reached in normal conditions. As an assertation can be used to verify the parameters passing to the private method. However, assertions should not be used to verify parameters passing to the public method, as there is no matter whether it is enabled, the public method must check its parameters. However, it can be used in public methods or in a non-public method to use asserts to test the post condition. In addition, the assertion should not change the status of the program in any way. 18. What is GC? Why do you have a GC? (Foundation). GC is a garbage collector. Java programmers don't have to worry about memory management because the garbage collector will automatically manage. To request garbage collection, one of the following methods can be called: system.gc () runtime.Gcuntime (). GC () 19, string s = new string ("XYZ"); create a few String Object? Two objects One is "XYX", one is a reference object S with "XYX". 20, Math.Round (11.5) Is Math.Round (-11.5) equal to? Math.Round (11.5) Return (long) 12, Math.Round (-11.5) Return (long) -11; 21, Short S1 = 1; S1 = S1 1; What is wrong? SHORT S1 = 1; S1 = 1; What is wrong? SHORT S1 = 1; S1 = S1 1; wrong, S1 is SHORT type, S1 1 It is int type and cannot be explicitly converted to a Short type. Can be modified to S1 = (Short) (S1 1). Short S1 = 1; S1 = 1 is correct. 22, SLEEP () and WAIT () What is the difference? The favorite SLEEP () method of making thread is to stop the thread to stop a period of time. After the SLEEP time interval is full, the thread does not necessarily resume it immediately.

This is because at that moment, other threads may be running and are not scheduled to give up execution, unless (a) "wake up" thread has higher priority (b) that is running because of other reasons. Wait () is a thread interaction if the thread issues a wait () call, the thread is suspended, the object is adjusted to the waiting state until it is awake or waiting time. 23 24. Is there a length () method for arrays? STRING has a length () method? The array does not have Length () method, with the properties of the length. String has a length () method. 25, the difference between overload and Override. OverLoaded method can change the type of return value? Override Overriding and overload 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. When the subject of subclass uses this method, the definition of the subclass will be called. For it, the definition in the parent class is like "shielded". If a plurality of the same names are defined in a class, they or have different parameters or different parameter types, called overloading. The way OVERLOADED is to change the type of return value. 26, the elements in Set cannot be repeated, then what method is used to distinguish whether it is repeated? Is it == or equals ()? What is the difference? The element in Set is not 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. 27, give me a Runtime Exception you most often.

ArithmeticException, ArrayStoreException, BufferOverflowException, BufferUnderflowException, CannotRedoException, CannotUndoException, ClassCastException, CMMException, ConcurrentModificationException, DOMException, EmptyStackException, IllegalArgumentException, IllegalMonitorStateException, IllegalPathStateException, IllegalStateException, ImagingOpException, IndexOutOfBoundsException, MissingResourceException, NegativeArraySizeException, NoSuchElementException, NullPointerException, ProfileDataException, ProviderException, RasterFORMatException, SecurityException, What is the difference between systemException, undeclaredthrowableexception, unmodifiableteextException, unsupportedOperationException 28, error and exception? Error indicates a serious problem that recovery is not impossible but very 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. 29, List, SET, MAP inherits from the Collection interface? List, SET is MAP is not 30, what is the difference between Abstract Class and Interface? The presence of a declaration method does not implement its class called an abstract class (Abstract Class), it Used to create a class that reflects certain basic behavior and declares the class for this class, but cannot implement this class 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 an 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, this method is implemented in the subclass. 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, no probabilities. 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. When the class implements a special interface, it defines the method of all such an interface (that is, the program body is given). Then, it can call the interface to call the interface on any object of the class of the interface. Because there is an abstract class, it 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 a slave interface type, and the InstanceOf operator can be used to determine whether an object is implemented.

31. Is Abstract to Method to be static, whether it is Native to Native, can you be synchronized? (Concrete Class)? 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. 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 that the thread will run immediately. The Run () method can generate a flag that must be exited to stop a thread. 34. Is the constructor can be inherited by the Override® constructor constructor, so Overriding cannot be overridden, but Overloading can be overloaded. 35, can you inherit the String class? The String class is not inherited by the final class. 36. After 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. 37, Try {} has a Return statement, then the Code keeping in the finally {} after this try, will not be executed, when is executed, before returnome or after it will be executed, execute before return. 38. Program: 2 multiplied by 8 equals with 8 equals? Programmers with C background particularly like to ask this question. 2 << 3 39, the two object values ​​are the same (x.equals (y) == true), but there is a different Hash code, this sentence is wrong? No pair, there is the same haveh code. 40. 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. The Java programming language is only passed by the value. When an object instance is transmitted to the method as a parameter, the value of the parameter is a reference to the object. The content of the object can be changed in the called method, but the reference to the object will never change. 41. If SWTICH can act on Byte, whether it can act on long, whether it can act on String? Switch (expr1), EXPR1 is an integer expression. Therefore, the parameters passing to the Switch and the CASE statement should be int, short, char or byte. Long, String can not work on SWTICH. 42. 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 Get a reference to it, then calls it.

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 should be more secure Some HashTable and HashMap HashTable inherited from the Dictionary class, and HashMap is a real-time Map Interface of the Java 1.2 introduced HashMap allows NULL as a key or value of the entry, and HashTable is not allowed. That is, Hashmap removes the Hashtable's Contains method, changed to ContainSvalue and Containskey. Because the Contains method is easy to cause misunderstandings. The biggest difference is that the HashTable method is Synchronize, and HashMap is not, when accessed HashTable, does not need to be synchronized for its method, and HashMap must provide external synchronization. Hash / rehash algorithms used by HashTable and Hashmap are probably, so performance will not have a big difference. 43. Describe the principle mechanism of the JVM load Class file? 44. Test example shows a typical garbage collection algorithm? 45. Use the Java to write the binary algorithm to implement the addition of data to form a binary tree function, and print it in a preface. 46. Please write a Java program to implement the thread connection pool function? 47. Given a C language function, require implementation to call in the Java class.

48, a piece of code is implemented after the console inputs a set of numbers, after being sorted in the console output; 49, list all files under a folder; 50, call the system command to delete the file operation; 51, achieve A character is read in a file; 52, list some of the control flows; 53, what states? 54. Writing a server-side program implementation is displayed on the client input character and displayed on the console until "end" is input, let you write the client's program; 55, scope public, private, protected, and do not write Difference A: The difference is the following: Scope Current class Package children's grandson class other package public √ √ √ √ protected √ √ × × Friendly √ √ × × private √ × × × Non-write time defaults to Friendly 56, ArrayList and Vector Difference ARRAYLIST and Vector mainly from the second aspect. I. Synchronization: Vector is a thread safe, that is, ArrayList is unsafe, not synchronous Data growth: When you need to grow, Vector default growth is the original training, and ArrayList is half a half of Hashmap and HashTable mainly from three aspects. I. Historical reasons: HashTable is an implementation of the old Dictionary class. Hashmap is an implementation of the MAP interface introduced by Java 1.2. Synchronism: HashTable is the thread security, that is, HashMap is not safe. , Not synchronized three. Value: Only HashMap allows you to use null values ​​as a key or value 57 of a table, can CHAR type variables Can CHAR type variables? Why? A: It is possible to define a Chinese Because Java is encoded in Unicode, a char accounts for 16 bytes, so a Chinese is no problem 58. There are several implementation methods for multi-threading. What is it? Synchronize several implementation methods, what? A: Multi-thread has two implementation methods, which are two kinds in inheriting the THREAD class and implementing the implementation of Runnable interface synchronization. SYNCHRONIZED, WAIT and Notify 59, garbage collection mechanism, how to optimize the program? I hope everyone will make up, thank you 60, float type float f = 3.4 is it correct? A: incorrect. The accuracy is inaccurate, should be converted with mandatory type, as shown below: float f = (float) 3.4 61, introduce the Collection Framework in Java (including how to write your own data structure)? A: Collection Framework as follows: Collection ├List │├ LinkedList │ ├ARRAYLIST │ ├Stack └SET MAP HashTable ├Shmap └weakhashmap Collection is the most basic set interface, a Collection represents a group of objects, Elements Map provides key to value map 62, Abnormal handling mechanism, event mechanism in Java? 11. Proffles and inheritance in Java? I hope everyone will make up, thank you 63, abstract class and interface? A: Abstract class and interface are used for abstraction, but the abstract class (Java) can have its own partial implementation, and the interface is completely an identifier (both multiple inheritance functions).

Program: 1. Now enter N numbers, separately, separate; then select liter or descending order; click on the submit button to display what is sorted by another page, the result is, providing a reset answer (1) 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;} loop traversing string array integer.parseint (String s) becomes INT The type consists of INT array arrays.sort (int [] a), A array ascending descending order can output 2 from the tail. The amount converted, the amount of the Arab figures converted into Chinese traditional forms such as (¥ 1011) -> (1 thousand and one yuan) output.

3, the execution order of the class is generally a choice question, ask you how to print it? A: Parent class: package test; public class fatherclass {public fatherclass () {system.out.println ("FatherClass Create ");}} subclasses: package test; import test.FatherClass; public class ChildClass extends FatherClass {public ChildClass () {System.out.println (" ChildClass Create ");} public static void main (String [] args) {FatherClass fc = new FatherClass (); ChildClass cc = new ChildClass ();}} the output:? C:> java test.ChildClass FatherClass Create FatherClass Create ChildClass Create 4, the internal implementation class a: the following sample code: package test; public class OuterClass {private class InterClass {public InterClass () {System.out.println ( "InterClass Create");}} public OuterClass () {InterClass ic = new InterClass (); System.out.println ( "OuterClass Create ");} public static void main (String [] args) {OuterClass oc = new OuterClass ();}} The output: C:> java test / OuterClass InterClass Create OuterClass Create a further example: public class OuterClass {private double D1 = 1.0; // INSERT CODE Here} You NEED TO INSE rt an inner class declaration at line 3. Which two inner class declarations are valid (Choose two.) A. class InnerOne {public static double methoda () {return d1;}}? B. public class InnerOne {static double methoda () {return d1;}} C. private class InnerOne {double methoda () {return d1;}} D. static class InnerOne {protected double methoda () {return d1;}} E. abstract class InnerOne {public abstract double methoda ( );} The description is as follows: 1. The static internal class can have a static member, not a static member. Therefore, A, B is wrong. The non-static member of the static internal class can access the external class static variables, and the non-static variables of the external class are not accessible; RETURN D1 error. Therefore, D is not three. Non-static members of non-static internal classes can access unstatic variables of external classes.

Therefore, C, E 5, Java communication programming, programming questions (or question and answer), programming, read servers, and write to local display with Java Socket A: Server side program: package test; import java.net *; import java.io. *; public class Server {private ServerSocket ss; private Socket socket; private BufferedReader in; private PrintWriter out; public Server () {try {. SS = New ServerSocket (1000); while (True) {socket = ss.accept (); string remoteip = socket.getinetaddress (). gethostaddress (); string remoteport = ":" socket.getlocalport (); system.out .println ( "A client come in IP:!" RemoteIP RemotePort); in = new BufferedReader (new InputStreamReader (socket.getInputStream ())); String line = in.readLine (); System.out.println ( " Cleint Send IS: " Line); OUT = New PrintWriter (Socket.getOutputStream (); out.println (" Your Message Received! "); Out.close (); in.close (); socket.close ()}}}}}} ("wrong");}}} public static void main (String [] args) {new server ();}}; client-side program: package test; import java .io. *; import java.net. *; public class client {socket socket; buffredreader in; printwriter out; public client () {Try { System.out.println ("Try to Connect To 127.0.0.1:10000"); socket = new socket ("127.0.0.1", 10000); System.out.Println ("The Server Connected!"); System.out, SYSTEM.OUT .println ( "Please enter some Character:"); BufferedReader line = new BufferedReader (new InputStreamReader (System.in)); out = new PrintWriter (socket.getOutputStream (), true); out.println (line.readLine () ); in = new buffreader (new input.getinputstream ())); system.out.println (in.readline ()); out.close (); in.close (); socket.close ();

} catch (ioException e) {outputln ("wrong");}} public static void main (string [] args) {new client ();}}; 6, using Java implement a sort, Java class implementation sequence Method (two)? As in the Collection framework, what kind of interface is to be achieved? A: Sort by the insertion method is as follows Package Test; import java.util. *; Class insertsort {arraylist al; public insertsort (int Num, int mod) {al = new arraylist (num); random rand = new random () System.out.println ("The ArrayList Sort Before:"); for (int i = 0; i

A: The code is as follows: package test; class SplitString {String SplitStr; int SplitByte; public SplitString (String str, int bytes) {SplitStr = str; SplitByte = bytes; System.out.println ( "The String is: '" SplitStr "'; Splitbytes =" splitbyte);} public void splitit () {int loopcount; loopcount = (splitstr.length ()% splitbyte == 0)? (Splitstr.length () / splitbyte) :( splitstr.length ) / Split byte 1); System.out.Println ("Will Split INTO" LoopCount; for (INT i = 1; i <= loopcount; i ) {if (i == loopcount) {system.out. Println (Splitstr.Substring ((i-1) * splitbyte, splitstr.length ()));} else {system.out.println (splitstr.substring ((i-1) * splitbyte, (i * splitbyte)))) }}} public static void main (STRING [] args) {splitstring ss = new splitstring ("TEST DD text DSAF in Men's 3443N China 43 Chinese 0ewldfls = 103", 4); ss.splitit (); } 8, Java multi-thread programming. Write a multi-thread program with Java, such as writing four threads, two plus 1, two to one variable minus one, output. I hope everyone will make up, thank you 9, String and StringBuffer. A: The length of String is invisible, and the length of StringBuffer is variable. If you use the content in the string, especially when you want to modify, use StringBuffer, if you finally need String, use StringBuffer's toString () method JSP aspect 1, what built-in objects do you have? A: JSP has the following 9 basic built-in components (can correspond to the six internal components of the ASP): Request User Request, this request will contain the parameter page of the Get / POST request response to the user's response to the pageContext page The attribute is here to manage the session period Application Servlet in the Session period Application Servlet, which is being executed. What is the role? A: JSP has the following six basic action JSP: include: Introduction: Introducing 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 Tag 3, Dynamic Include and Static Include in JSP according to the Java plugin according to the browser type? A: Dynamic include uses JSP: include Page = "incrude.jsp" flush = "true" /> It always checks the changes in the file included, suitable for using dynamic pages, and can bring The parameter static include uses the incrude pseudo code, which does not check the changes in the file included, suitable for use in the static page <% @ include file = "incruded.htm"%> 4, what is the two types of jump mode? What is it? Difference? A: There are two kinds, which are: The former page does not turn to Include refers to Page, just display the result of the page, the main page is still the original page. It will come back later, which is equivalent to the function call. And can be used with parameters. The latter is completely turned to a new page and will not come back. Equivalent to the GO TO statement. SERVET 1, saying that the life cycle of servlet? A: servlet has a good life definition, including loading and instantiation, initialization, processing request, and service end. This survival period is expressed by the init, service, and destroy method of the javax.servlet.servlet interface. 2, the servlet version (forgot this two of the two versions)? I hope everyone will make up, thank you 3, the Java Servlet API is different from the difference between () and redirect ()? A: The former is only the steering of the control of control in the container. It does not show the turn-behind address in the client browser address bar; the latter is completely jump, the browser will get the address of the jump, and re-re- Send a request link. Thus, the link address after the jump is seen from the address bar of the browser. Therefore, the former is more efficient, and when the former can meet the needs, try to use the forward () method, and this also helps to hide the actual link. In some cases, for example, you need to jump into a resource on a further server, you must use the sendRedirect () method.

4, Servlet basic structure public class ServletName extends HttpServlet {public void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {} public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {}} Jdbc, Jdo aspect 1 You may let you write a JDBC even Oracle program and implement data queries. A: Package hello.ant; import java.sql. *; Public class jdbc {string dburl = "JDBC: Oracle: Thin: @ 127.0.0.1:1521:0.0.1:1521:orcl "; string theuser =" admin "; string thepw =" manager "; connection c = null; statement conn; result} = null; public jdbc () {Try {class.forname (" Oracle. JDBC.Driver.Oracledriver "). NewInstance (); C = DriverManager.getConnection (dburl, theuser, thepw); conn = c.createstatement ();} catch (Exception E) {E.PrintStackTrace ();}} public boolean executeUpdate (String sql) {try {conn.executeUpdate (sql); return true;} catch (SQLException e) {e.printStackTrace (); return false;}} public ResultSet executeQuery (String sql) {rs = null; try { RS = conn.exe CATEQUERY (SQL);} catch (squexception e) {E.PrintStackTrace ();} return}} public void close (); c.close ();} catch (exception e) { E.PrintStackTrace ();}} public static void main (string [] args) {resultset {RST RS; JDBC conn = new jdbc (); rs = conn.executeQuery ("select * from test"); try {while (RS. Next ()) {system.out.println (rs.getstring ("id")); system.out.println (rs.getstring ("name"));}} Catch (Exception E) {E.PrintStackTrace () ;}}} 2, the role of class.forname? Why is it to use? A: Call this access Returns an object that is specified by a string class name. 3. What is JDO? A: JDO is a new specification for the Java object persistence, 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, so that the developer does not require additional code (such as the JDBC API). These cumbersome routines have been transferred to the JDO product provider, so that developers are freed out to concentrate on time and energy logically. In addition, JDO is flexible because it can run on any data underlayer. JDBC is just more common to relational database (RDBMS) JDO, providing storage capabilities of any data underlying, such as relational database, file, xml, and object database (ODBMS), etc., make it stronger to apply portability. 4. Subject solution in Oracle's large amount of data. Generally, the ID method is used, and there is a three-layer nested method.

A: One page method <% int i = 1; int number = 14; string pages = request.getParameter ("page"); int currentpage = 1; currentpage = (Pages == NULL)? (1): {Integer .PARSEINT (PAGES)} SQL = "SELECT Count (*) from Tables"; ResultSet RS = DBLINK.EXECUTEQUERY (SQL); while (rs.next ()) i = rs.Getint (1); int intelectCount = 1; ? intPageCount = (i% numPages == 0) (i / numPages) :( i / numPages 1); int nextPage; int upPage; nextPage = currentPage 1; if (nextPage> = intPageCount) nextPage = intPageCount; upPage = CurrentPage-1; if (UPPage <= 1) UPPAGE = 1; rs.close (); SQL = "Select * from Tables"; rs = dblink.executeQuery (SQL); i = 0; While ((i // Output content // Output page connection total: <% = currentpage%> / <% = intPageCount%> First Page Previous <% for (INT J = 1; J <= INTPAGECUNT; J ) {IF (CurrentPage! = j) {%> Next Page Wang Xiaoming Information School 6258113 Born in 1955, Ph.D., 95 years of imported Hainan University

private String currentElement = null; private String currentValue = null; public void setTable (Hashtable table) {this.table = table;} public Hashtable getTable () {return table;} public void startElement (String tag, AttributeList attrs) throws SAXException { currentElement = tag;} public void characters (char [] ch, int start, int length) throws SAXException {currentValue = new String (ch, start, length);} public void endElement (String name) throws SAXException {if (currentElement. Equals (name)) Table.Put (Currentelement, CurrentValue);}} JSP content display source code, saxml.jsp: Analyze XML file people.xml </ title> </ head> <body > <% @ Page ErrorPage = "Errpage.jsp" ContentType = "text / html; charset = GB2312"%> <% @ page import = "java.io. *"%> <% @ page import = "java.util .Hashtable "%> <% @ page import =" org.w3c.dom. * "%> <% @ Page import =" org.xml.sax. * "%> <% @ Page import =" javax.xml. Parsers.saxparserfactory "%> <% @ Page Import =" javax.xml.parsers.saxparser "%> <% @ page import =" saxhandler "%> <% File File = New File ( "c: /people.xml"); FileReader reader = new FileReader (file); Parser parser; SAXParserFactory spf = SAXParserFactory.newInstance (); SAXParser sp = spf.newSAXParser (); SAXHandler handler = new SAXHandler ( ); sp.PARSE (New InputSource (Reader), Handler; Hashtable HashTable = handler.getTable (); Out.println ("<Table Border = 2> <Caption> Teacher Information Table </ CAPTION>"); OUT. Println ("<tr> <td> Name </ TD>" "<TD></p> <p>" (String) HashTable.Get (New String (" Name ")) " </ td> </ tr> "); out.println (" <tr> <td> "</ td>" "< TD> " (String) HashTable.Get (New String (" College ")) " </ TD> </ TR> "); out.println (" <tr> <td> phone </ td> " "<TD>" (String) HashTable.Get (New String ("Telephone") "</ td> </ tr>"); out.println ("<tr> <td> Remarks </ TD> " " <TD> " (String) HashTable.Get (New String (" Notes ")) " </ TD> </ TR> "); Out.println (" </ Table> ");%> </ Body> </ html> EJB: What are the contents of EJB2.0? What is the difference between EJB2.0 and EJB1.1? A: The specification includes the bean provider, the application assembly, EJB Container, EJB Configuration Tool, EJB Service Provider, System Administrator. This, EJB container is the reason that EJB can run. EJB container manages EJB creation, undo, activation, deactivation, connection to the database, etc. Important core work. JSP, Servlet, EJB, JNDI, JDBC, JMS ..... 2, EJB and JAVA bean Differences? A: Java bean is a reused component, and there is no strict specification for Java Bean, In theory, any Java class can be a bean. But usually, since Java Bean is created by the container (such as Tomcat), Java Bean should have a 11-free constructor, in addition, usually Java Bean It is also necessary to implement the SERIALIZABLE interface to implement the persistence of bean. 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 .Enterprise Java bean is equivalent to DCOM, which is distributed component It is based on Java-based remote method call (RMI) technology, so EJB can be remotely accessed (cross-process, cross computer). But EJB must be deployed in a container such as WebSpere, WebLogic, EJB customers never directly Access the true EJB component, but through its container .e The JB container is an agent of EJB components, and the EJB component is created and managed by the container. The client accesses the real EJB component through the container.</p> <p>3, EJB A basic structure: an EJB comprises three parts: Code package Beans Remote Interface interface; import javax.ejb.EJBObject; import java.rmi.RemoteException; public interface Add extends EJBObject {// some method declare} Home Code package Beans Interface interface; import java.rmi.RemoteException; import jaax.ejb.CreateException; import javax.ejb.EJBHome; public interface AddHome extends EJBHome {// some method declare} EJB class code package Beans; import java. RMI.RemoteException; import javax.ejb.sessionBean; import javx.ejb.sessionContext; public class addbean imports sessionBean {// some method Declare} J2EE, MVC side 1 A: MVC is a short written by Model-View-Controller. "Model" is the application's business logic (implemented by javabean, ejb component), "view" is the application's representation surface (generated by JSP page), "Controller" is a process control (generally a servlet) The application logic, processing procedure, and display logic are achieved by this design model into different components. These components can interact and reuse. 2, the difference between application servers and web server? I hope everyone will make up, thank you 3. What is J2EE? A: JE22 is a multi-dimi-Diered, distributed, distributed, component-based, based on Component-Base, in which an application system can follow Function is divided into different components that can be on different computers and are in the corresponding hierarchy (TIER). The hierarchies are included in the ClientN Tier components, web layers, and components, Business layers, and components, and corporate information systems (EIS) layers. 4. Web service noun explanation. JSWDL development package. JAXP, JAXM explanation. SOAP, UDDI, WSDL Explanation. A: Web Service Description Language WSDL SOAP, Simple Object Access Protocol, is a lightweight protocol for exchange XML encoding information. The purpose of UDDI is to establish standards for e-commerce; UDDI is a web-based, distributed, implementation standard specification provided by the information registry for Web Service, and also includes a group of web services that can provide themselves. Register to achieve the implementation of the access protocols that other companies can discover. 5, links and differences between BS and CS. I hope everyone will make up, thank you 6, Struts application (such as Struts Architecture) A: Struts is an open source of the open source using Java Servlet / JavaServer Pages technology, developing the web application's open source Framework. The Struts can develop an application architecture based on MODEL-View-Controller design mode.</p> <p>Struts has the following main functions: I contain a controller servlet to 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. Design patterns 1, the development is used in the development model? What are the occasion? A: Each mode describes a problem that appears in our environment and then describes the core of the solution. In this way, you can use the existing solutions countlessly without counting the same job. Mainly used in the design pattern of MVC. Used to develop JSP / Servlet or J2EE related applications. Simple factory model, etc. 2, UML Answer: Standard Modeling Language UML. Modal example, static diagram (including class diagram, object map, and package), behavioral diagram, interaction (sequential diagram, cooperation map), implementation diagram, JavaScript, how to check digital type? Var RE = / ^ D { 1, 8} $ | .d {1, 2} $ /; var str = document.form1.all (i) .value; var r = str.match (re); if (r == null) {sign = -4; Break;} else {document.form1.all (i) .value = PARSEFLOAT (STR);} CORBA: What is CORBA? What is the use? A: CORBA standard is a public object request agency structure (Common Object Request Broker Architecture, standardized by the object management organization (Object Management Group, abbreviated as OMG). 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 to use different programming languages ​​to run in different processes in different processes to develop Linux, 1, Linux, thread, and GDI classes. A: Linux implementation 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. Java Huawei Interview Java Aspect 1 Object-Oriented Features What is the most basic data type? 3 INT and Integer What is the difference between 4 String and StringBuffer? Is there a difference in unusual abnormalities during 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.</p> <p>6 Speak some common class, package, interface, please raise 5 7 to say that ArrayList, Vector, LinkedList's storage performance and features ArrayList and Vector are stored in an array mode, and the number of elements is greater than the actual stored data. In order to increase and insert elements, they all allow direct sequence number index elements, but inserted into memory operations such as array elements, so the index data is fast and the data is slow, and the vector is used by the Synchronized method (thread security), usually Compared to ArrayList, the LinkedList uses a two-way linked list to store, pressing the number index data to perform forward or rear traversal, but only the front and rear items of this item are required when inserting data, so the insertion speed is faster. 8 Design 4 threads, two threads increase 1 each time, and 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 incmplements 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. The built-in object and method of JSP. Request Request represents the HTTPServletRequest object. It contains information about the browser request and provides a number of methods for obtaining cookie, header, and session data. Response Response represents the HTTPServletResponse object and provides several methods for setting the response to the browser (such as cookies, header information, etc.) OUT OUT objects are an instance of javax.jsp.jspwriter, and provide several ways You can use to return the output results to your browser. PageContext PageContext represents a javax.servlet.jsp.pageContext object. It is an API for convenient access to various range spaces, servlet-related objects, and wraps a generic Servlet related feature. Session session represents a request Javax.Servlet.http.httpsession object.</p> <p>Session can store the status information of the user Application Applicat Indicates a Javax.Servlet 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 Page Represents a servlet instance 10 generated from this page. Writing communication with the Socket communication, requiring the customer to return the same data after sending data. See the Socket Communication in the course. 11 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, the request is reached, the service method is automatically dispatched with the DOXXX method (Doget, DOPOST) corresponding to the request, and calls its Destroy when the server decides to destroy the instance. method. The difference from the CGI is that the servlet is in the server process, which runs its service method by multithreading, and an 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 completed, it is destroyed, so it is less efficient than servlet. 12.EJB is based on which technologies are implemented? And say the difference between SessionBean and EntityBean, the differences of Statefulbean and STATELESSBEAN. 13. EJB includes (sessionbean, entitybean) says their life cycle, how to manage transactions? 14. What is the working mechanism of the data connection pool? 15 Synchronous and asynchronous and different, use them in what circumstances? for example. 16 What are the application servers? 17 What are your collections you know? Main method? 18 Give you: Driver A, Data Source Name B, the user name is C, the password is D, the database table is T. All the data of the table T is retrieved with JDBC. 19. Say how to make a pagination in the JSP page? Page needs to save the following parameters: Total line number: get the number of lines per page according to the SQL statement: Set value Current page: Request parameter page According to the current number of pages and each page The number calculates the number of lines of the first line of the current page. The positioning result set is set to this line, and the result set takes out the line of the number of rows per page. Database: 1. Different stored procedures for stored procedures and functions are a collection of user-defined SQL statements, involving tasks for specific tables or other objects, users can call stored procedures, and functions are usually the method defined by the database, it Receive parameters and returns a certain type of value and does not involve specific user tables. 2. What is the transaction? The transaction is a series of operations performed as a logical unit, and a logical work unit must have four attributes, called ACID (atomic, consistency, isolation, and persistent) attributes, only this can become a transaction: atomic transaction It must be an atomic work unit; for its data modification, it is either executed, or all do not execute. When the consistency is completed, all the data must be consistently held. In the relevant database, all rules must be used to modify the transaction to maintain all data integrity. At the end of the transaction, all internal data structures (such as B tree indexes or bidirectional linies) must be correct. Isolation is made by concurrent amendments must be isolated from any other concurrent business.</p> <p>Transaction View the status of data when data is displayed, or another concurrent transaction modifies its previous state, or another transaction modifies the state after it, the transaction does not view the data of the intermediate state. This is referred to as serialization because it can reload the starting data and replay a series of transactions so that the status at the end of the data is the same as the original transaction. After the durability transaction is completed, its impact on the system is permanent. This modification will remain maintained even if there is a system failure. 3. The role of the cursor? How do you know that the cursor has arrived at the end? The cursor is used for the line of positioning result set, and by judging that the global variable @@ fetch_status can determine whether the final change is usually, this variable is usually not equal to 0 to indicate an error or finally. 4. The trigger is divided into an existing trigger and post-event trigger, which triggers and distinctions. What is the difference between statement level trigger and row trigger. The prior trigger is running before the trigger event occurs, and after the event is running after the trigger event occurs. Usually the prior trigger can get the event before and the new field value. Statement-level triggers can be executed before or after execution of statements, while the row triggers each row that triggered in the trigger. COLVETION Test 1, object-oriented three basic feature 2, method overload and method rewriting concept and distinction 3, interface and internal class, abstract class characteristics 4, file read and write basic class ** 5, serial Precautions and how to achieve serialization 6, thread basic concept, thread's basic state, and state between the relationship 7, the synchronization of the thread, how to achieve thread synchronization 8, several common data structures and internal implementation principles . 9, Socket Communication (TCP, UDP Difference, Java Implementation) ** 10, Java Event Principal Mechanism and Garbage Recycling Mechanism 11, JDBC Call Database Basic Step ** 12 Java's four basic permissions 14. Java's international SP 1, at least 7 implied objects and their distinction ** 2, Forward and Redirect 3, JSP common instructions, servlet 1, call doget () and dopost () under what circumstances? 2, servlet's init () method and service () method distinguish 3, the lifecycle of servlet 4, how realistic servlet single-thread mode 5, Servlet configuration 6, four session tracking technology four, EJB ** 1, EJB The services provided by the container primarily provide services such as declaration cycle management, code generation, continuous management, security, transaction management, lock and distribution management.</p> <p>2, EJB role and three object EJB roles mainly include the Bean Developer Application Assessor Deployer System Administrator EJB Container Provider EJB Server Provider's three objects are Remote (local (localhome) interface, Bean class 2. Several type sessions of EJB (session) beans beans beans-driven (entry) bean session beans can be divided into stateful and stateless two entity beans can be divided into BEAN management persistence (BMP) and Continuity (CMP) of container management (CMP) 3, the lifecycle of the bean instance For the STATELESS Session bean, the Entity Bean generally has buffer pool management, and for the Entity Bean and Statefull Session BEAN has Cache management, usually contains an instance, set context, create EJB Object (create), service method call, remove, etc., the instance of the buffer pool management does not remove from memory, but use buffer The pool scheduled mechanism continues to reuse the instance, and the BEAN for the presence of Cache is maintained and the active mechanism holds the state of the bean and limits the number of instances in the memory. 4, the activation mechanism is in the STATEFULL SESSION bean as an example: its Cache size determines the number of bean instances that can be present in the memory, according to the MRU or NRU algorithm, the instance is migrated between activation and deactivation state, the activation mechanism is when the client When you call an EJB instance business method, if you do not bind the corresponding bean instance you don't bind the corresponding bean (by serializing mechanism storage instance) Reply (activation) this instance. The corresponding EJBACTIVE and EJBPASSIVATE methods are called before the state change. 5, the REMOTE interface and the home interface main REMOTE interface defines the business method. The HOME interface is used for EJB client calling business method HOME interface is an EJB factory for creating and removing the EJB instance 6. Several basic steps for the customer service call EJB object First, set the JNDI service factory and the JNDI service address system attribute, find the Home interface, call the CREATE method from the Home interface, create the Remote interface, call its business method 5, database 1, store procedure 2, basic SQL statement six, WebLogic 1, how to give Weblogic Specify size memory? In the Script of WebLogic's script (located in the domian corresponding server directory), add set mem_args = -XMS32M -XMX200M, adjust the minimum memory 32m, maximum 200M 2, how to set the thermal start mode (development mode) of WebLogic 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 Comufact of the Commenv file, add set production_mode = true. 3. Do you need to enter a username and password when starting? Modify the service startup file, add WLS_USER and WLS_PW items.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-129292.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="129292" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.045</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'CMxCX7qLw9zsea0u4YBYSbe2EZD09XLpaaZujl_2BZdyk4Vze9MHkNBjqk4M_2BtZeLqYnj1ZgmILDFAPjBE'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>