Java EE Basic Concept (summary)

Source: Internet
Author: User
Tags empty end execution garbage collection object model string version variable
j2ee| Concept Java Basics:

1, scope public,protected,private, and the difference when not written

The difference between 2,arraylist and vectors, HashMap and Hashtable.

Can 3,char variable be defined as one Chinese? Why?

4, there are several ways to express multithreading, what is it? There are several ways to achieve synchronization.

5, the Inheritance time class execution order question, generally is the choice question, asks you to be able to print what?

6, how to implement the inner class?

7, garbage collection mechanism, how to optimize the program?

Is the 8,float float f=3.4 correct?

JSP aspect

What are the built-in objects for 1,jsp? What is the difference?

What is the action of 2,jsp?

What are the differences between the two ways of implementing 3,include?

4, what is the difference between the two modes of jump?

servlet aspect

1, what is the lifecycle of a servlet?

What is the difference between the 2,servlet version (which has been forgotten about the two versions)?

JDBC,JDO aspects

1, you may be able to write a section of JDBC even Oracle program.

2,class.forname's role? Why should I use it?

What is 3,JDO?

XML aspects

What are the analytical techniques for 1,xml? What is the difference?

2, what aspects of XML technology have you used in your project?

3, how to solve the Chinese problem when parsing xml file with Jdom?

EJB aspect

What are the contents of 1,ejb2.0? The difference between EJB2.0 and EJB1.1?

MVC aspect

What are the techniques that are available in all parts of 1,MVC? How to achieve it?

Design pattern Aspect:

1. Which design patterns are used in the development? What's the occasion?

JavaScript aspect

1, how to verify the digital type?

Corba

What is 1,corba? What is the purpose?


Who will make the answer?
-------------------------------------------------------------
Part of the answer.
1, scope public,protected,private, and the difference when not written
The classes that public in other packages can also be referenced, protected are restricted to classes within the same package, and private only can be used by themselves. It's the same as protected when you don't write.
The difference between 2,arraylist and vectors, HashMap and Hashtable.
ArrayList need to be predefined in size, vector not. The default initialization capacity of the HashMap and Hashtable (initial capacity) differs HashMap is 16,hashtable 11.
Can 3,char variable be defined as one Chinese? Why?
can be defined. Because the Chinese is also 16bit.
4, there are several ways to express multithreading, what is it? There are several ways to achieve synchronization.
View the JDK documentation.
5, the Inheritance time class execution order question, generally is the choice question, asks you to be able to print what?
This specific to see.
6, how to implement the inner class?
An inner class is a class declared inside another class. Starting with Java 1.1, you can declare another class in one class, which is very similar to declaring fields and methods.
7, garbage collection mechanism, how to optimize the program?
Assign a variable to NULL when it is not in use.
Is the 8,float float f=3.4 correct?
No way. Type does not match. Change to float f=3.4f.

servlet aspect

1, what is the lifecycle of a servlet?
The lifecycle of a servlet is when the server mounts to run Servlets, receives multiple requests from the client and returns data to the client, and then deletes the servlets time.
What is the difference between the 2,servlet version (which has been forgotten about the two versions)?
I personally do not think that this question has any practical significance.
JDBC,JDO aspects

1, you may be able to write a section of JDBC even Oracle program.
There is a formula. Connection conn = null;
String Driver = "Oracle.jdbc.driver.OracleDriver";
String url = "Jdbc:oracle:thin: @xxx: 1521:xxx";
String user = "xxx";
String password = "xxx";
Try
{
Class.forName ("Oracle.jdbc.driver.OracleDriver");
conn = drivermanager.getconnection (URL, user, password);
}
catch (ClassNotFoundException e)
{
System.err.print ("Classnotfoundexception:load jdbc-driver failure!");
System.err.println (E.getmessage ());
}
catch (SQLException e)
{
E.printstacktrace ();
Try
{
IF (conn!= null)
{
Conn.close ();
conn = null;
}
}
catch (SQLException se)
{
}
}
2,class.forname's role? Why should I use it?
Returns a class object with the specified name. Use it to load the class that you specify a name for.
What is 3,JDO?
Full name Java Data Objects. Provides a clear persistence of the Java object model in a transactional database, directly supporting instances of Java classes, and the application does not have to deal with any other data model.

XML aspects

What are the analytical techniques for 1,xml? What is the difference?
1 CSS is the abbreviation of cascading style sheet, that is, "cascading style sheet", in 1997, when the HTML4 standard was promulgated, the first standard CSS1 about the style sheet was also published.
2 XSL (extensible style Language, extensible Style language) is the most powerful and flexible style language, designed specifically for application of XML, and it completely follows XML rules to further refine the XML itself.
3) Data-island. There are a few more, but mainly the second one, other I think is not the mainstream.
2, what aspects of XML technology have you used in your project?
xslt,fo,html parsing, XML data encapsulation and parsing. Implemented using a third party package.
3, how to solve the Chinese problem when parsing xml file with Jdom?
No, I'm not sure. I use the castor. (In Jbuilder9)

JavaScript aspect

1, how to verify the digital type?
isNaN (parsefloat (XXX)) If true, is not a number.
---
Do something to complement:
(1) Vector methods are synchronous (Synchronized), are thread-safe (thread-safe), and
ArrayList method is not, because the thread synchronization must affect performance, therefore, ArrayList performance than
Vector good.
(2) When the element in the vector or ArrayList exceeds its initial size, the vector doubles its capacity and
ArrayList only increases the size of 50%, so that ArrayList can save memory space.
(3) Hashtable is based on the old dictionary class, HashMap is a Java 1.2 introduced map interface of a
An implementation.
(4) Performance comparisons are similar to vectors and ArrayList, such as the Hashtable method is synchronized, and
HashMap's not.
(5) Only HashMap can let you use NULL as the key or value of a table entry
---
What are the analytical techniques for 1,xml? What is the difference?

There are two kinds: Dom and sax.

DOM: You can get a tree structure that contains all the elements in a document.
SAX: Events are generated at different points in the document, and the application can decide how to handle these events to get information from the parser.
---
Java Basics: (not written is already answered or I myself also unknown or uncertain)

4, there are several ways to express multithreading, what is it? There are several ways to achieve synchronization.
:::
I know that there are two ways to achieve this:
One is to synchronize the method: Public synchronized methodname (...) {....}
The other is to synchronize the object (this object cannot be a null value): Synchronized (objects) {...}

5, the Inheritance time class execution order question, generally is the choice question, asks you to be able to print what?
The execution order of the classes at the time of inheritance is:
The part of the parent class that is defined by the Static keyword is initialized first in the order in which it is defined;
The parent class constructor (in order of invocation);

The part defined by the static keyword in a subclass is first initialized in the order defined;
Subclass Constructors (in order of invocation);
Others are in the order of invocation of the method.

6, how to implement the inner class?
public class xxxxx{//Only one public

...

Class yyyyy{//available access types are [protected | private | none]
...
}

}

Is the 8,float float f=3.4 correct?
I don't know whether it is right or not.
I am generally like this: float f=3.4f; or float f=3.4f;//followed by an English uppercase or lowercase letter F
---
JavaScript aspect

1, how to verify the digital type?
var v = document.all.Telephone.value;
if (isNaN (v)) {
Alert ("All numbers");
}
---
Yangtaylor explanation more than half of it is wrong, we do not make the standard answer back OH
Noisysilence's explanation is very good, you are already a master, but the point is that vector's subtle setting is the second parameter set, the rest are basically correct.

A description of the scope public,protected,private and differences when not written---
The first three commonly used, needless to say, about not writing when I explain:
Java scope In fact there are 5 kinds, in addition to the above 3 kinds of: private Protected,default
Public--------------don't talk.
Protected-----------except that all subclasses are accessible, non-subclasses of the same package can also access
Private-------------won't say anything.
Private protected---Only subclasses can be accessed (this is the protected in the sense that we understand)
Default-------------only classes with packages can be accessed, even subclasses but different packages are still inaccessible

I also read a lot of reference books to finally get the result, here to everyone.
---
The difference between the ArrayList and the vector has been said, I say they will bring about the impact.
The same object collection, ArrayList can be checked by the compiler and the vector does not, so if you return the collection of objects with vector, the compiler is not able to detect the error, only at run time can be found. For example:
Using vector*************
Server side:
Public Vector getcustomdataset (int num)
{
Vector v = new vector ();
for (int i=0; i<num; i++)
{
CustomData customdata = new CustomData (i);
V.add (CustomData)//Where custom data structures are added CustomData
}
return v;
}
Client side:

Vector v = getcustomdataset (5);
for (int i=0; i<v.size (); i++)
{
Otherdata data = (otherdata) v.get (i);//Here The CustomData is removed and converted to Otherdata, and the compiler passes
}

Using arraylist*************
Server side:
Public customdata[] Getcustomdataset (int num)
{
customdata[] CustomData = new CUSTOMDATA[5];
for (int i=0; i<num; i++)
{
Customdata[i] = new CustomData (i);
}
return customdata;
}
Client side:

customdata[] Datas = Getcustomdataset (5);
for (int i=0; i<datas.length; i++)
{
Otherdata data = datas[i];//compilation does not pass, type mismatch
}

---
The bottom is the difference between Hashtable and HashMap I've been looking for.


Hashtable and HashMap
There are three important differences between the Hashtable and the HashMap classes. The first difference is mainly historical. Hashtable is based on the stale dictionary class, and HashMap is an implementation of the map interface introduced by Java 1.2.
Perhaps the most important difference is that the Hashtable method is synchronized, and the HashMap method is not. This means that although you can use a hashtable in a multithreaded application without taking any special actions, you must provide an external synchronization for a hashmap as well. A convenient approach is to take advantage of the static Synchronizedmap () method of the collections class, which creates a thread-safe map object and returns it as an encapsulated object. This object's approach allows you to synchronize access to potential hashmap. The result is that when you don't need to sync, you can't cut the sync in the Hashtable (like in a single-threaded application), and the synchronization adds a lot of processing overhead.
The 3rd difference is that only hashmap can let you use NULL as the key or value of a table entry. Only one record in HashMap can be an empty key, but any number of entries can be empty value. This means that if the search key is not found in the table, or if the search key is found, but it is an empty value, then get () returns NULL. If necessary, use the Containkey () method to distinguish between these two situations.
Some data suggest, when need synchronization, use Hashtable, converse with HashMap. However, because HashMap can be synchronized when needed, HashMap functions more than Hashtable, and it is not based on a stale class, so it is argued that HashMap takes precedence over Hashtable in all situations.
---
Programming interfaces for XML: DOM SAX JDOM JAXP

The Document Object model (commonly called DOM) defines a set of interfaces for the parsed version of an XML document. The parser reads the entire document and then constructs a tree that resides in memory, and your code can manipulate the tree structure using the DOM interface. You can traverse the tree to see what the original document contains, you can delete several parts of the tree, and you can rearrange the tree and add new branches
DOM provides a rich set of features that you can use to interpret and manipulate XML documents, but use them for a price.
The DOM constructs the entire document-resident memory tree. If the document is large, it will require a great deal of memory.
The DOM creates objects that represent everything in the original document, including elements, text, attributes, and spaces. If you just focus on a small part of the original document, creating objects that will never be used is extremely wasteful.
The DOM parser must read the entire document before your code gets control. For very large documents, this can cause significant delays


To solve the DOM problem, the Xml-dev participants (led by David Megginson) created the SAX interface. Several features of SAX solve the DOM problem:

The SAX parser sends events to your code. It tells you when the parser discovers the start of the element, the end of the element, the text, the beginning or end of the document, and so on. You can decide what events are important to you, and you can decide what type of data structure you want to create to hold the information from those events. If you do not explicitly save data from an event, it is discarded.
The SAX parser does not create any objects at all, it simply passes events to your application. If you want to create objects based on those events, this will be done by you.
The SAX parser starts sending events at the beginning of parsing. When the parser discovers the start of the document, the start of the element, and the text, the code receives an event. Your application can start building results immediately; you don't have to wait until the entire document is parsed. Even better, if you only find something in your document, the code can throw an exception once it finds what you're looking for. The exception stops the SAX parser, and the code uses the data it finds to do whatever it needs to do.
The SAX parser also has some issues that are interesting:

SAX events are stateless. When the SAX parser finds text in an XML document, it sends an event to your code. The event only gives you the text you find; it does not tell you what elements contain that text. If you want to know this, you must write your own state management code.
SAX events are not persistent. If your application needs a data structure to model an XML document, you must write that code yourself. If you need to access data from a SAX event and don't store that data in code, you'll have to parse the document again.

JDOM is an Open-source project based on Java technology that tries to follow the 80/20 rule: Meet the needs of 80% of users with DOM and SAX 20% capabilities. JDOM uses SAX and DOM parsers, so it is implemented as a relatively small set of Java classes.

The main feature of JDOM is that it drastically reduces the number of code you have to write. Although this introductory tutorial does not delve into programming topics in depth, the length of the JDOM application is typically one-third of the DOM application, about half the size of a SAX application. (Of course, purists who insist on using DOM suggest that learning and using DOM will eventually pay off in the long run). JDOM doesn't do everything, but for most of the parsing you want to do, it might just fit you.

Although DOM, SAX, and JDOM provide standard interfaces for most common tasks, there are still things that they cannot solve. For example, the process of creating an Domparser object in a Java program differs depending on the DOM parser. To fix this problem, Sun publishes JAXP (Java api,java API FOR XML parsing for XML parsing). This API provides a common interface for processing XML documents using DOM, SAX, and XSLT.

The interfaces that JAXP provides, such as Documentbuilderfactory and Documentbuilder, provide a standard interface for different parsers. There are also methods that allow you to control whether the underlying parser recognizes namespaces and uses DTDs or schemas to validate XML documents.
To determine which interface is right for you, you need to understand the design essentials for all interfaces, and you need to understand what your application does with the XML document that you will be working on. Consider the following questions to help you find the right approach.

Do you want to write your application in Java? JAXP uses DOM, SAX, and JDOM; If you write code in Java, you should use JAXP to isolate your code from the specifics of the various parser implementations.
How will the application be deployed? If your application is going to be deployed as a Java applet, you will want to minimize the number of code you want to download, and don't forget that the SAX parser is smaller than the DOM parser. Also know that using JDOM requires a small amount of code to be written in addition to SAX or DOM parsers.
Once you parse an XML document, do you need to access that data more than once? If you need to go back and access the parsed version of the XML file, DOM might be the right choice. When a SAX event is triggered, if you need it later, you (the developer) decide to save it in some way. If you need to access an event that has not been saved, you must resolve the file again. And the DOM automatically saves all the data.
Do you need only a small amount of content for the XML source file? If you only need a small amount of content in an XML source file, SAX might be the right choice. SAX does not create objects for everything in the source file; you want to determine what is important. With SAX, you check each event to see if it has something to do with your needs, and then process it accordingly. Even better, once you find what you're looking for, your code throws an exception to completely stop the SAX parser.
Are you working on a machine with little memory? If so, SAX is your best bet, regardless of what other factors you might consider.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.