[置顶] java面试题经典20例【第三季】

1bean实例的生命周期

       对于Stateless Session BeanEntity BeanMessage Driven Bean一般存在缓冲池管理,而对于Entity BeanStatefull Session Bean存在Cache管理,通常包含创建实例,设置上下文、创建EJB Objectcreate)、业务方法调用、remove等过程,对于存在缓冲池管理的Bean,在create之后实例并不从内存清除,而是采用缓冲池调度机制不断重用实例,而对于存在Cache管理的Bean则通过激活和去激活机制保持Bean的状态并限制内存中实例数量。

2、如何设定的weblogic的热启动模式(开发模式)与产品发布模式?

可以在管理控制台中修改对应服务器的启动模式为开发或产品模式之一。或者修改服务的启动文件或者commenv文件,增加set PRODUCTION_MODE=true

3、说说你所熟悉或听说过的j2ee中的几种常用模式?及对设计模式的一些看法

     Session Facade Pattern:使用SessionBean访问EntityBean

Message Facade Pattern:实现异步调用

EJB Command Pattern:使用Command JavaBeans取代SessionBean,实现轻量级访问

Data Transfer Object Factory:通过DTO Factory简化EntityBean数据提供特性

Generic Attribute Access:通过AttibuteAccess接口简化EntityBean数据提供特性

Business Interface:通过远程(本地)接口和Bean类实现相同接口规范业务逻辑一致性

EJB架构的设计好坏将直接影响系统的性能、可扩展性、可维护性、组件可重用性及开发效率。项目越复杂,项目队伍越庞大则越能体现良好设计的重要性

4HashMapHashtable的区别。

HashMapHashtable的轻量级实现(非线程安全的实现),他们都完成了Map接口,主要区别在于HashMap允许空(null)键值(key,由于非线程安全,效率上可能高于Hashtable.

5Collection Collections的区别。

Collection是集合类的上级接口,继承与他的接口主要有SetList.

Collections是针对集合类的一个帮助类,他提供一系列静态方法实现对各种集合的搜索、排序、线程安全化等操作。

6GC是什么?为什么要有GC?

GC是垃圾收集的意思(Gabage Collection,内存处理是编程人员容易出现问题的地方,忘记或者错误的内存回收会导致程序或系统的不稳定甚至崩溃,Java提供的GC功能可以自动监测对象是否超过作用域从而达到自动回收内存的目的,Java语言没有提供释放已分配内存的显示操作方法。

7、数组有没有length()这个方法? String有没有length()这个方法?
数组没有length()这个方法,有length的属性。
String有有length()这个方法。

8OverloadOverride的区别。Overloaded的方法是否可以改变返回值的类型?
方法的重写Overriding和重载OverloadingJava多态性的不同表现。重写Overriding是父类与子类之间多态性的一种表现,重载Overloading是一个类中多态性的一种表现。如果在子类中定义某方法与其父类有相同的名称和参数,我们说该方法被重写 (Overriding)。子类的对象使用这个方法时,将调用子类中的定义,对它而言,父类中的定义如同被屏蔽了。如果在一个类中定义了多个同名的方法,它们或有不同的参数个数或有不同的参数类型,则称为方法的重载(Overloading)Overloaded的方法是可以改变返回值的类型。

9Set里的元素是不能重复的,那么用什么方法来区分重复与否呢?是用==还是equals()?它们有何区别?
Set
里的元素是不能重复的,那么用iterator()方法来区分重复与否。equals()是判读两个Set是否相等。
equals()==方法决定引用值是否指向同一对象equals()在类中被覆盖,为的是当两个分离的对象的内容和类型相配的话,返回真值。
10errorexception有什么区别?
error
表示恢复不是不可能但很困难的情况下的一种严重问题。比如说内存溢出。不可能指望程序能处理这样的情况。
exception 表示一种设计或实现问题。也就是说,它表示如果程序运行正常,从不会发生的情况。

11、介绍一下Log4J特点及用法?(5)

Log4J 是Apache的一个开发源代码项目,它是一个日志操作包,可以指定日志信息的输出地,如控制台、文件、GUI组件等。还可以控制每一条日志的输出格式,定义日志的输出级别。

要使用Log4J总体上可以分为下面的3步

1 获取日志记录器

2读取日志配置文件,文件名默认为 Log4j.properties

3输出日志信息

 

12、叙述一下spring是怎么和struts整合的。(5)

首先,SpringContextLoaderPlugin StrutsActionServlet装载 Spring应用程序环境。,简单地向您的 struts-config.xml文件添加该插件,

<plug-in className=

  "org.springframework.web.struts.ContextLoaderPlugIn">

    <set-property property=

      "contextConfigLocation" value="/WEB-INF/beans.xml"/>

 </plug-in>

通过在struts-config动作映射中注册一个代理类(DelegatingActionProxy来实现,这样就把struts动作交给spring来管理,代理负责在 Spring 环境中查找 Struts动作。由于动作在 Spring的控制之下,所以它可以填充动作的 JavaBean属性,并为应用诸如 Spring AOP 拦截器之类的特性带来了可能。

13、在struts中怎样配置多个strust-config.xml(4)

在web.xml文件中,配置一个<servlet>节点,为其指定多个

<init-param>

            <param-name>config/unfilter</param-name>

            <param-value>/WEB-INF/unfilter/struts-config.xml</param-value>

    </init-param>节点,就可以实现多个struts-config.xml配置文件。

14、运行时异常与一般异常有何异同?
异常表示程序运行过程中可能出现的非正常状态,运行时异常表示虚拟机的通常操作中可能遇到的异常,是一种常见运行错误。java编译器要求方法必须声明抛出可能发生的非运行时异常,但是并不要求必须声明抛出未被捕获的运行时异常。

 

 

15、Which statement shows the maximum salary paid in each job category of each department?____b___(4)
A. select dept_id, job_cat,max(salary) from employees where salary > max(salary);


B. select dept_id, job_cat,max(salary) from employees group by dept_id,job_cat;
C. select dept_id, job_cat,max(salary) from employees;
D. select dept_id, job_cat,max(salary) from employees group by dept_id;
E. select dept_id, job_cat,max(salary) from employees group by dept_id,job_cat,salary;

16)description of the students table(4)
  sid_id                       number
  start_date                   date
  end_date                     date
which two function are valid on the start_date column?_____c__e__。
A.sum(start_date)
B.avg(start_date)
C.count(start_date)
D.avg(start_date,end_date)
E.min(start_date)
F.maximum(start_date)

17)for which two constraints does the oracle server implicitly create a unique index?______be。(4)
A. not null
B. primary
C. foreign key
D. check
E. unique

18)in a select statement that includes a where clause,where is the group by clause placed in the select statement?____e__。(4)
A. immediately after the select clause
B. before the where clause
C. before the from clause
D. after the order by clause
E. after the where clause

19)in a select statement that includes a where clause,where is the order by clause placed in the select statement?_____c.(4)
A.immediately after the select clause
B.before the where clause
C.after all clause
D.after the where clause
E.before the from clause

20)evaluate there two sql statements____a__.(4)
Select last_name,salary from employees order by salary;
Select last_name,salary from employees order by 2 asc;
A.the same result  B.different result C.the second statement returns a syntax error

原文地址:https://www.cnblogs.com/xinyuyuanm/p/3031484.html