Java基础知识1

1. Difference between sleep() & wait()

  http://www.cnblogs.com/DreamSea/archive/2012/01/11/JavaThread.html#Introduction

  http://www.cnblogs.com/DreamSea/archive/2012/01/16/SleepAndWaitDifferent.html

2. When use assert

3. EJB(SessionBean, EntityBean), the life cycle of them and how to manage transaction?

4. Singleton

  http://www.cnblogs.com/garinzhang/archive/2013/04/01/2994031.html

  http://www.cnblogs.com/garinzhang/archive/2013/04/04/2999331.html

5. Four technical in page:

a. Page: only limit in current page, for property/object/attribute

b. Request: sent from client, transform parameter to server and other page

c. Session: used to record the use authority

d. Application: web server, contain all, global variable

6. J2EE is a platform or framework? What technology J2EE contains?

a. J2EE is a standard, a for Enterprise Distributed Application standard platform

b. Also is a framework, contain JDBC, JNDI, RMI, JMS, EJB, JTA and so on.

7. What services provide by EJB container?

a. Life cycle management, code management, continue management, security, transaction management, lock, concurrent

8. 23 J2EE design pattern

a. Factory, Builder, Factory Method, Prototype, Singleton, Façade, Adapter, Bridge, Composite, Decorator, Flyweight, Proxy, Command, Interpreter, Visitor, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Chain Of Responsibleity

9. Often use package and class, interface:

a. Package: java.util, java.io, java.sql, javax.servlet, java.exception, java.lang

b. Class: String, Integer, ArrayList, FileReader, FileWriter, BufferedWriter, BufferedWriter

c. Interface: Collection, List, Map, SortedMap, Iterator

10. What is JDO?

a. Java persistent new standard. Java Data Object, use to save/fetch object of datahourse's new standard API

11. Factory Design pattern:

a. Factory:

i. Creator

ii. Concrete Creator

iii. Product

iv. Concrete Product

b. Abstract Factory:

i. Abstract Factory

ii. Concrete Factory

iii. Abstract Product

iv. Concrete Factory

12. Difference between abstract factory & factory method

a. Abstract factory: have many product abstract product class and only one factory abstract class, the factory can generate all products

b. Factory method: have many abstract factory class, only one product abstract class, every factory can only generate one product

参考:http://leayer.iteye.com/blog/907953

13. Difference for forward, include, reDirect

a. Forward: server jump and return the resource to client

b. Include: include dynamic page, jsp

i. <%@ include file="" %> // involve static file(.html), not check the file content

ii. <jsp:include page="" flush="true" /> // involve dynamic file(*.jsp)

c. reDirect: server sent link to client and browser jump

14. ArrayList & Vector, HashMap, HashTable & HashSet

a. ArrayList & Vector: thread safe(Vector),

b. HashMap(Unthread safe), HashTable(thread safe), HashSet(Unduplicate elements)

15. Difference between Statement & PreparedStatement?

a. PreparedStatement is more safe than Statement

b. PreparedStatement is pre-compile, have good efficient for batch sql, also call JDBC procedure

c. Statement, when only need one time save/fetch database, recommend to use it. The cost of PreparedStatement is bigger than Statement, so for one-time operate database recommend use Statement.

d. Oracle will cache the sql of PreparedStatement, when next invoke the Oracle will cache the sql of PreparedStatement, when next invoke the sql with different value, the efficient will bigger.

16. How to iterate a collection:

Iterator I = colllection.iterator();

While(i.hasNext()){

System.out.println(i.next())

}

For(Object o:colllection) {

System.out.println(0);

}

17. Reverse the string, such as input abc, and out put is cba

String str = "abc";

Char[] ch = str.toCharArray();

Char[] ch1 = new char[ch.length];

For(int I = ch.length - 1, j = 0; I >= 0 ; i--) {

Ch1[j] = ch[i];

j++;

}

String str = new String(ch1);

18. Sort int array:

Int[] data = {5, 3, 7, 4, 8, 9, 4, 3, 5}

Int temp;

For(int I = data.length - 1; I >= 0; i--) {

For(int j = 0; j < i; j++) {

    If(data[j] > data[j+1]) {

        Temp = data[j]

         Data[j] = data[j+1];

        Data[j+1] = temp;

    }

}

}

路慢慢其休远羲,吾将上下而求所
原文地址:https://www.cnblogs.com/garinzhang/p/2537276.html