Java foundation: 1. Scope public, protected, private, and non-write distinction: differences: Scope Current classpublic √ √ √ √Protected √ √ × Friendly √ × × Private √ × × × [Does not write when default is friendly] ====================================== = 2. The difference between Hashmap and HashTABLE: ARRAYLIST and VECTOR mainly from the second aspect: I. Synchronization: Vector is thread security, that is, the synchronization, and arraylist is a line program. Not safe, not synchronized. Data growth: When you need to grow, Vector default growth is the original training, and ArrayList is the original half of Hashmap and HashTable mainly from three aspects: 1. History: Hashtable is Based on 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 unsafe, not synchronous. Value: Only Hashmap allows you to take null value as a table of key or value- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (HashTable and Hashmap mainly is the former is synchronized, the latter is a fast failure mechanism guarantee that there will be no multi-threaded concurrency error (Fast-fail). When you initialize a HashTable, you can specify Two parameters: initial capacity, load, these two parameters strongly affect the performance of HashTable. Capacity refers to the number of objects, and the load is the number of objects and capacities of the actual stored object in the list. If the initial capacity too Small, then HashTable needs constant expansion and rehash (), which is time consuming; if the initial capacity is too large, it will cause waste of space. Contrary to the load, the load is too small to cause space waste, and the load is too large and will time consuming (because this will cause more keywords to repeat, "HashTable uses a link table to store these repeating disappears) . The default value of the capacity is 11. The default value of the load is 0.75. In general, you can use the default value to generate a HashTable. In addition, most of the methods in HashTable are synchronized.
) ======================================= 3, CHAR type variables can not be defined as one Chinese? Why? A: Yes, because Java is encoded in Unicode, a char accounts for 16 bits.
================================================================================================================================================================================================ What? Synchronize several implementation methods, what is it? A: Multi-thread has two implementation methods, which inherit the Thread class and implementation of the implementation of the Runnable interface synchronization, Synchronized, Wait and Notify == ========================================================================================================================================================================================== Select question, ask what you will print? A: For example: package sun; public class a {public a () {system.out.println ("Hello, A!");}} Package sun; import sun. A; // public class b extends a {public b () {system.out.println ("Hello, B!");} Public static void main (String [] args) {a aa = new a (); b BB = new b ();}} This program is wrong! ! / * Print Result: Hello, A! Hello, A! Hello, B! * / ================================ ============================================ 6, the internal class implemented method? A: sample code is as follows: 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: InterClass CreateOuterClass Create a further example: public class OuterClass {private double d1 = 1.0; // insert code here} You need to insert an inner class declaration at line 3. Which two inner classdeclarations 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. Non-static members of static internal classes can access the external class static variables, and the unstatic variables of the external class; 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 correct answer (C, e) ========================================== ======================== 7, how can I optimize the program? A: How do you answer this question? First, Java has an automatic garbage collection mechanism, which is different from C . When an object is no longer referenced or is set, it meets the conditions of the garbageware.
Garbage collection does not collect reference, but collects objects !! Garbage collection is a separate low-priority thread that can call instance GC () to activate garbage collection, but not guarantee the garbage collection will start immediately ===== ============================================================================================================================================================================================================= ========== 8, FLOAT type float f = 3.4 is it correct? A: No, the accuracy is not accurate, you should use forced type conversion, as shown below: float f = (float) 3.4 === ============================================================================================================================================================================================================= ============ JSP, what built-in objects do you have? What is the role? 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 to respond to the user end response to the properties of the pageContext web page is here to manage the session period Application Application Servlet is being executed by the contents of the content OUT to transmit the response. Output Config Servlet architecture Page JSP page itself Exception For error web pages, unconcerned exceptions ============================== ========================================================================================================================= 2? What is the following? A: JSP has the following 6 Basic Action JSP: Include: Introduces 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, the difference between the two implementations of include: 1. Dynamic include : Include Action Implementation It always checks the changes in the file included, suitable for use in the dynamic page, and can be used with parameters 2. Static include 码 码, customize the change of the file included, suitable for inclusion Static page <% @ include file = "included.htm"%> =================================== ============================== 4, what is the difference between the two jump mode? A:
The frontier page does not turn to the page referred to in INCLUDE, 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 you can take a parameter. The latter is completely turned to the new page, and will not return again.
Come. Equivalent to the GO TO statement.
============================================================================================================================================================================================================= ================
Servlet
1, talk about the life cycle of servlet?
A: The servlet has a good definition of survival, 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 to ask which two versions of the question)?
What is this version of this version? ^ - ^
============================================================================================================================================================================================================= ==
JDBC, JDO
1, you may let you write a JDBC even Oracle program.
Example:
Package hello.ant;
Import java.sql. *;
Public Class JDBC
{
String dburl = "JDBC: Oracle: Thin: @ 127.0.0.1: 1521: ORCL";
String theuser = "admin";
String thepw = "manager";
Connection C = NULL;
STATEMENT CONN;
ResultSet RS = 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.executeQuery (SQL);
}
Catch (SQLException E)
{
E.PrintStackTrace ();
}
Return RS;
}
Public void close ()
{
Try
{
CONN.CLOSE ();
C. close ();
}
Catch (Exception E)
{
E.PrintStackTrace ();
}
}
Public static void main (string [] args)
{
ResultSet 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, Class.Forname role? Why is it used?
Thinking in Java
============================================================================================================================================================================================================= ================
3, what is JDO?
A: JDO is a new norm of Java object persistence, which is a referred to as Java Data Object, is also an access to some kind.
Standardization API of the object in the data warehouse. JDO provides transparent object storage, so storage for developers
The data object does not require additional code (such as the JDBC API). These cumbersome routines have been transferred to
JDO product providers have made developers from liberalization, and concentration time and energy logically logically. In addition, J
Do it is flexible because it can run on any data underlayer. JDBC is just a relational database (RDBMS) JDO more
Use, provide storage features to any data underlayer, such as relational database, file, XML, and object database (ODB
MS), etc., make it stronger to apply portability
============================================================================================================================================================================================================= ================
XML aspect
1, what parsing technology is there? Is there anything?
A: There are DOM, SAX, Stax, etc.
DOM: It is very powerful when processing large files. This problem is caused by the tree structure of the DOM. This structure is more memory, and the DOM must be before parsing the file.
The entire document is loaded into memory, suitable for random access to XML
SAX: Not present in DOM, SAX is an event-driven XML parsing method. It sequentially reads the XML file, no need to all
Replace the entire file. When encountered at the beginning of the file, the end of the document, or the label starts with the end of the tag, it will trigger one
Event, users handle XML files by writing processing code in their callback events, suitable for the order of XML
Stax: streaming API for XML (stax)
============================================================================================================================================================================================================= ================
2. What are your aspects of XML technology in the project? How to implement it?
A: Data storage, information configuration is two aspects. When doing a data exchange platform, the data source cannot be assembled into
XML file, then transmit XML file compression package encryption and transfer to the recipient through the network, receive decryption and decompression
Restore relevant information in the XML file for processing. When doing software configuration, it can be easily performed using XML.
Various configuration parameters are stored in the XML file.
============================================================================================================================================================================================================= ================
3. How to solve Chinese problems when using JDOM to resolve the Chinese problem? How to resolve?
A: Look at the following code, solve the encoding method
Package test;
Import java.io. *;
Public Class Domtest
{
Private string infile = "c: //people.xml";
Private string outfile = "c: //people.xml";
Public static void main (string args [])
{
New domtest ();
}
Public domtest ()
{
Try
{
Javax.xml.parsers.documentbuilder builder =
Javax.xml.Parsers.DocumentBuilderFactory.newInstance ().
NewDocumentBuilder ();
Org.w3c.dom.document doc = builder.newdocument ();
Org.w3c.dom.Element root = doc.createElement ("teacher");
Org.w3c.dom.Element Wang = Doc.createElement ("King");
Org.w3c.dom.Element Liu = Doc.createElement ("Liu");
Wang.Appendchild (Doc.createTextNode ("I am Teacher"))
Root.appendchild (wang);
Doc.Appendchild (root);
Javax.xml.transform.transformer Transformer =
Javax.xml.transform.transformerFactory.newinstance (). NewTransformer ()
;
TRANSFORMER.SETOUTPUTPROPERTY (javax.xml.transform.outputKeys.Encoding,
"GB2312");
Transformer.setputputProperty (javax.xml.transform.outputKeys.indent,
"yes");
Transformer.Transform (New Javax.xml.Transform.dom.Domsource (DOC),
New javax.xml.transform.Stream.StreamResult (outfile);
}
Catch (Exception E)
{
System.out.println (E.getMessage ());
}
}
}
============================================================================================================================================================================================================= ================
EJB aspect
1. What are the contents of EJB2.0? What are the differences in 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. In this regard, the EJB container is the core of EJB. EJB container manager EJB creation
, Withdraw, activation, live, and database connection, etc. Important work. JSP, Servlet, EJB, JNDI, JDB
C, JMS .....
============================================================================================================================================================================================================= ================
MVC aspect
1, all parts of MVC have those technologies to achieve? How to implement?
A: MVC is a short written by Model-View-Controller. "Model" represents the application's business logic (implemented by javabean, EJB component), "view" is the application's representation surface (generated by JSP page), "controller" is
Providing application processing process control (generally a servlet), through this design model, dealing with application logic, processing
Cheng and display logic are divided into different component implementations. These components can interact and reuse.
============================================================================================================================================================================================================= ================
Design mode:
1. Use the design mode in the development? What are the occasions?
A: Each mode describes a problem that has emerged in our environment and then describes the solution to the problem.
The core of the case. In this way, you can use the existing solutions in numerous times without counting the same.
jobs. Mainly used in the design pattern of MVC. Used to develop JSP / Servlet or J2EE related applications. Simple factory
Mode, etc.
============================================================================================================================================================================================================= ================
JavaScript
1. How do I verify digital?
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
1. What is CORBA? What is the use?
A: CORBA standard is a public object request agency structure (Common Object Request Broker Architecture
), Standardized by object management organizations (Object Management Group, abbreviated as OMG). Its composition is the interface
Language (IDL), language binding (Binding: also translated as a connection) and an agreement to interoperate interoperability. Its purpose
for:
Written in different programming languages
Run in different processes
Development of different operating systems
*********************************************************** ************************************************************
I. Java basic knowledge 1. Java has those basic data types, String is the basic data type, what is the difference they have. Integer Literals, Floating-Point Literals, Character Litrals, Boolean Litral, String Iteral. String is not basic data type 2. String operation: Write a method to implement strings, such as input ABC, output CBA public static string Reverse (string s) {intlength = s.Length (); stringbuffer result = new stringbuffer (length); for (int i = length-1; i> = 0; I -) Result.Append (S.Charat) i)); return result.toString ();} Write a method to implement the replacement of the string, such as input BBBWLIRBBB, output BBBHHTCCC. 3. Conversion between data types How to convert numeric characters into numbers (Integer, Double) how to convert digital to characters to the first two digits, and go all over. 4. How to get the date and time of the year, hourly second DATE DAT = new date (); dat.getyear (); dat.getDay (); dat.getHours (); ... Get the number of milliseconds from 1970 to the current mill (); how to get a date is how to format the date DateFormate DF = DateFormate.getinstance (); DFMAT (DAT); 5. Arranges and Collections 6. Documents and Directory (I / O) Operation How to list all the files in a directory how to list all subdirectories in a directory to determine if there is a file or directory how to read and write 7. Java Implementation (inheritance, overloading, overlay) 8. Coding conversion, how to convert a string encoded by GB2312 into ISO-8859-1 encoded strings. 9. The difference between step, statement, and preparedStatement accessed in Java. 10. Find out the error that the following code may exist and explain the reason: Second, JSP & Servlet technology 1. Describe the differences between JSP and Servlets, common, and respective applications 2. What should I do when I need to handle HTML tags in web development? The processing is to filter those characters (<> & ") 3. Read the client's request in JSP, how to access the CGI variable, how to determine the true path of a JSP file. 4. Describe the role, differences between cookie and session, and their respective applications, and the SESSION work. 5. What is the difference between the two people who contain external files in the JSP. 6. Describe the role of ErrorPage in JSP, application range. 7. Explain how to use JavaBeans in JSP. 8. Simple introduction to the JSP tag library 9. How to forward the request forwarding in the JSP and Servlets. Third, J2EE related knowledge 1. Introduce the difference between J2EE, J2SE, J2SE. 2. J2EE is a technology or a platform that provides those technologies. 3. What is Application Server, what features and advantages it is. 4. Briefly introduce the advantages and principles of the connection pool.
5. WEB.XML's role 4, other 1. Web security considerations (form validation, authentication of browser Basic mode, application security, SSL, code consideration) 2. Simple introduce your MVC. 3. Briefly introduce the XML you know. 4. Documents and Coding Specifications 5. Paging, efficiency considerations in Java. 6. Briefly introduce the Structs you know. Find out the following procedures. Class test {private string par1; private string par2; test () {} public static void main (string [] arg) {Int a; if (a) {system.out.println ("par1 =" par1);} Else {system.out.println ("PAR2 =" PAR2);}}}
*********************************************************** *********************************************************** ***********
1.
Abstract class name {
PRIVATE STRING NAME;
Public Abstract Boolean isstupidName (String Name) {}
}
What is wrong with the heroes?
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. No access modifiers (private, public, and protected) before local variables
. Final can be used to modify partial variables
(Final like Abstract and Strictfp
It is non-access modifier, and stricTFP can only modify Class and ME.
THOD is not a variable).
3.
Abstract class something {
Private abstract string dosomething ();
}
It seems that there is nothing wrong?
Answer: wrong. Abstract Methods cannot be modified with private
. Abstract Methods is to make subclass item IMPLEMEN
T (implementation) specific details, how can I use Private Abstract?
CT
What is the Method blocking? (Similarly, Final can't add Final before Abstract Method).
4.
Public class something {
Public Int Addone (Final 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.
script>
Public class something {public static void main (String [] args) {
Other o = new other ();
New Something (). Addone (O);
}
Public void addone (Final Other O) {
O.I ;
}
}
Class other {
Public INT I;
}
It is very similar to the above, it is about Final 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
(Such as: o = new other ();), then the question is also wrong as the above example. But here is modified here is
MEMBER VAIRABLE
(Member variable), while the Reference Reference did not change.
6.
Class Something {
INT I;
Public void dosomething () {
System.out.println ("i =" i);
}
}
Is there anything wrong? I 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 default value. INT's default value is 0.
7.
Class Something {
Final INT I;
Public void dosomething () {
System.out.println ("i =" i);
}
}
There is only one place with one of the above questions, that is, there is 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. It can be changed to "S.DOSMETHING () Returns" S.DOSomething ()); ". Similarly, Static Method cannot access Non-Static Instant Variable.
9.
Here, the file name of the Something class is called Othershing.java
Class Something {
Private static void main (string [] Something_to_do) {
System.out.println ("Do Something ...");
}
}
This seems to be obvious.
Answer: Correct. No one has said that the Java's Class name must be the same as its file name. But the name of the public class must be the same as the file name.
10.
The hardest question today:
Interface playable {
Void Play ();
}
Interface bounceable {
Void Play ();
}
Interface Rollable Extends Playable, Bounceable {Ball Ball = New Ball ("pingpang");
}
Class ball imports 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 Play, Bounceable" is no problem. Interface can inherit multiple Interfaces, so it is right. The problem is in the Interface Rollable "Ball Ball = New Ball (" pingpang ");". Any Interface Variable (interface variable, or member variable) declared in Interface, the default is public static final. That is, "Ball Ball = New Ball (" pingpang ");" actually "public static final ball ball = new ball (" pingpang ");". In the Play () method of the Ball class, "football"); "Change the Ball Reference, and the Ball from Rollable Interface, the ball in the Rollable Interface is public static final, Final Object It is not possible to change Reference. Therefore, the compiler will be "Ball = New Ball (" football ");" it is wrong here.