java中文英文面试题库.docx_第1页
java中文英文面试题库.docx_第2页
java中文英文面试题库.docx_第3页
java中文英文面试题库.docx_第4页
java中文英文面试题库.docx_第5页
已阅读5页,还剩19页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

JAVA最新面试题-附英文面试题Heroyanglei 1、当一段SQL执行很慢时,应该怎样调优?/shenglam/article/details/72075521. check the database if it is working well.2. have a overview of volume these tables. 3. check the tables which we need to invoke. if they are opened by any other users. and whether are blocked.4. look into indexs of the tables.5. check the sql , and find out the symbol which will impact the performance. like IN, UNION LIKE and so on.6. on the basis of the volume, determine the query criteria. like the order of the tables.7. deeply to find out the reason. 2、Struts和Webwork相比较,Webwork有什么优点? 3、谈谈Spring的IOC和AOP的用途及优点。/basic-concepts-of-spring/1. IOC : inversion of control. AOP: Aspect oriented programming.2. Hence easier for dependency injection /injection of test data,3. with the dependency injection(DI) approach, dependencies are explicit and evident in constructor or JavaBean properties.4. Enhances modularity. provider more readable codes.5. Provides loose coupling between different modules.6. Effective in organizing the middle-tier applications.7. Flexible use of dependency injection. Can be configured by XML based schema or annotation-based style.8. Support declarative transaction, caching, validation and formatting.9. /sin90lzc/archive/2012/07/14/2587227.html 4、悲观锁和乐观锁的概念。/questions/129329/optimistic-vs-pessimistic-locking1. the disadvantage of pessimistic locking is that a resource is locked from the time. it is first accessed in transaction until the transaction is finished, making it inaccessible to other during that time. If most transactions simply look at the resource and never change it, an exclusive lock may be overkill as it may cause lock contention.2. with optimistic locking a resource in not actually locked when it is first accessed by a transaction. Instead, the state of the resource at the time when it would have been locked with the pessimistic locking approach is saved. Other transaction are able to concurrently access to the resource and the possibility of conflicting changes is possible. At commit time, when the resource is about to be updated is persistent storage. the state of the resource is read from storage again and compared to the state that was saved when the resource was first accessed in the transaction. If the two states differ. a conflicting update was made, and the transaction will be rolled back. 5、是否使用过webservice,用的是哪种webservice,有什么好处?1. yes, SOAPand REST.2. /articles/rest-soap-when-to-use-each3. REST: a. Lightweight - Not a lot of extra xml markup.b. Human readable result. more readable.c. Easy to build - not toolkits required.4. SOAP:a. Easy to consume - sometimes. its important to note that one of advantage of SOAP is use of the generic transport. while REST today uses HTTP/HTTPS, soap can use almost transport to send the request. However, one disadvantage is use of XML because of the verboseness of it and the time it takes to parse.b. rigid - type checking, adheres to contract.c. Development tools. also the disadvantage.技术面试:请列出5个您所回答的问题? 1、请说说最近项目中使用的技术 2、举例说明你软件开发过程中的数据设计原则 3、针对并发数据访问,你有何策略? 4、熟悉存储过程和数据库引擎吗? 5、项目管理过程中,你怎么控制风险? String与String Buffer的区别, 既然有了StringBuffered为什么还需要String(difference between String and StringBuffer ;why String is needed,given)1. /rmn190/article/details/14920132. string class is used to manipulate character string that cannot be changed. Simply stated, objects of type string are read only and immutable.3. the stringbuffer class is used to represent characters that can be modified./javaworld/jw-03-2000/jw-0324-javaperf.html Statement和PreparedStatement之间的区别(difference between statement and preparedstatement ,why using the preparedstatement)1. prepared statement is pre-compiled class. but statement is not. so in PreparedStatement the execution will be faster.2. Actually when u submit a simple statement to the database, at first the DBMS parses it and sends it back with the result, so again when u send the same statement again the DBMS parses it and sends back the result so here a lot of time is wasted and because the statement is again parsed though it has been sent twice or thrice it consume a lot of time and response will be slow. 3. Actually when u submit a simple statement to the database, at first the DBMS parses it and sends it back with the result, so again when u send the same statement again the DBMS parses it and sends back the result so here a lot of time is wasted and because the statement is again parsed though it has been sent twice or thrice it consume a lot of time and response will be slow. 4. Prepared statement is used when u want to execute a statement object many times. when u submit a preparedstatement the DBMS server parse it and creates a execution plan. This e-plan can used when u again send the same statement to the database. That is the DBMS server fast executes the compiled statement. And also the advantage of using this preparedstatement it is used to send dynamic sql statements. which u can give values later than giving the at he time of creation. tomcat内存溢出原因1. /tech/2012-10-29/66913.html2. 里根据平时遇到的情况和相关资料进行一个总结。常见的一般会有下面三种情况:3. 1.OutOfMemoryError: Java heap space4. 2.OutOfMemoryError: PermGen space5. 3.OutOfMemoryError: unable to create new native thread.6. Tomcat内存溢出解决方案7. 对于前两种情况,在应用本身没有内存泄露的情况下可以用设置tomcat jvm参数来解决。(-Xms -Xmx -XX:PermSize -XX:MaxPermSize)8. 最后一种可能需要调整操作系统和tomcat jvm参数同时调整才能达到目的。9. 第一种:是堆溢出。10. 在JVM中如果98的时间是用于GC且可用的 Heap size 不足2的时候将抛出此异常信息。11. 没有内存泄露的情况下,调整-Xms -Xmx参数可以解决。12. -Xms:初始堆大小13. -Xmx:最大堆大小14. 但堆的大小受下面三方面影响:15. 1.相关操作系统的数据模型(32-bt还是64-bit)限制;(32位系统下,一般限制在1.5G2G;我在2003 server 系统下(物理内存:4G和6G,jdk:1.6)测试 1612M,64为操作系统对内存无限制。)16. 2.系统的可用虚拟内存限制;17. 3.系统的可用物理内存限制。18. 堆的大小可以使用 java -Xmx*M version 命令来测试。支持的话会出现jdk的版本号,不支持会报错。19. -Xms -Xmx一般配置成一样比较好比如set JAVA_OPTS= -Xms1024m -Xmx1024m20. 第二种:永久保存区域溢出21. PermGen space的全称是Permanent Generation space,是指内存的永久保存区域。这一部分用于存放Class和Meta的信息,Class在被 Load的时候被放入PermGen space区域,它和和存放Instance的Heap区域不同,GC(Garbage Collection)不会在主程序运行期对PermGen space进行清理,所以如果你的APP会LOAD很多CLASS的话,就很可能出现PermGen space错误。这种错误常见在web服务器对JSP进行pre compile的时候。但目前的hibernate和spring项目中也很容易出现这样的问题。可能是由于这些框架会动态class,而且jvm的gc是不会清理PemGen space的,导致内存溢出。22. 这一个一般是加大-XX:PermSize -XX:MaxPermSize 来解决问题。23. -XX:PermSize 永久保存区域初始大小24. -XX:PermSize 永久保存区域初始最大值25. 这一般结合第一条使用,比如 set JAVA_OPTS= -Xms1024m -Xmx1024m -XX:PermSize=128M -XX:PermSize=256M26. 有一点需要注意:java -Xmx*M version 命令来测试的最大堆内存是 -Xmx与 -XX:PermSize的 和 比如系统支持最大的jvm堆大小事1.5G,那 -Xmx1024m -XX:PermSize=768M 是无法运行的。27. 第三种:无法创建新的线程。28. 这种现象比较少见,也比较奇怪,主要是和jvm与系统内存的比例有关。29. 这种怪事是因为JVM已经被系统分配了大量的内存(比如1.5G),并且它至少要占用可用内存的一半30. 开发流程介绍请求的分发请求首先到达DispatcherServlet,应用服务器会根据Web应用中web.xml文件定义的url映射将相应的请求分发到DispatcherServlet中请求的处理DispatcherServlet会查找相应的HandlerMapping接口的实现类,调用其中的方法:HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception,该方法会返回一个HandlerExecutionChain。返回的HandlerExecutionChain中包含了零个或者是多个Interceptor和一个处理请求的Handler。DispatcherServlet会调用Interceptor中的preHandle() 方法。然后处理Handler,这个Handler相当于Struts中Action,在SpringMVC中默认的实现是Controller接口,是具体处理请求的代码所驻留的地方。事实上HandlerExecutionChain中的getHandler()返回的是一个Object类型。DispatcherServlet不会直接调用getHandler()返回对象中的方法,DispatcherServlet会查找相应的HandlerAdapter,然后具体通过HandlerAdapter来调用getHandler()返回的handler对象中的方法。就是说我们可以实现自己的HandlerAdapter然后通过IoC注入到DispatcherServlet中,从而可以实现一套自定义的控制器。随后DispatcherServlet会调用Interceptor中的postHandle()方法。视图的处理DispatcherServlet会期望Hander返回一个ModelAndView,DispatcherServlet会根据所返回的ModelAndView对象所包含的信息进行视图的渲染。起具体出来流程如下:首先DispatcherServlet会根据LocaleResolver来识别请求中的Locale,开发人员可以自己实现LocaleResolver接口,然后通过IoC注入到DispatcherServlet中,然后DispatcherServlet会判断ModelAndView中是否已经包含了接口View的具体实现,如果包含了,则直接调用View中的方法render(Map model, HttpServletRequest request, HttpServletResponse response)。如果不包含,则说明该ModelAndView只是包含了View的名称引用,DispatcherServlet会调用ViewResolver中的resolveViewName(String viewName, Locale locale)来解析其真正的视图。该方法会返回一个View的具体实现。视图的渲染Spring支持多种视图技术,其中比较常用的包括有Jstl视图,Veloctiy视图,FreeMarker视图等。对Jstl视图的渲染Spring是通过JstlView这个类具体实现的。事实上其最终的渲染是交给容器来做的,Spring只是通过RequestDispatcher实现了服务器内部请求的Forward。而对于模板视图,如Veloctiy和FreeMarker等,Spring会初始化其相应的模板引擎,由模板引擎生成最终的Html页面然后在合并到Response的输出流中。异常的处理如果在Hander中处理请求是抛出异常,DispatcherServlet会查找HandlerExceptionResolver接口的具体实现,该接口定义了一个方法:ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex),实现类需要实现该方法以便对异常进行处理,最后该方法需要返回一个ModelAndView。SpringMVC的一些总结 灵活的Interceptor,通过Interceptor我们可以在一个请求处理前和请求处理完成之后做相应的操作,通过Interceptor机制,我们可以做authentication, logging, and filtering等。 良好的表单支持,在SpringMVC的Controller继承体系结构中,其具体的子类对表单(Form)提供了良好的支持。能够很好的支持单个表单的显示、修改、提交操作。同时也提供了表单的分步提交。 可定制的数据绑定(Data Binding)。 多视图技术的支持,SpringMVC同时支持Jstl, Velocity 等多中视图技术,但是这同时也会引出一个问题,因为各种视图技术都有自己的一套方法来处理国际化,例如Jstl和Velocity处理国际化的方式就很不相同。因此在多个视图技术并存的应用中,国际化也是一个需要注意的问题。 其Handler(控制器)作为Bean定义在Spring容器中,因此能享受容器带来的服务。 Handler(控制器)具有良好的可测试性。 springmvc流程1. webservice介绍1. REST SOAP js输入校验 SERVLET的生命周期1. init() - service() - destroy() 在项目中如何实现tag ajax工作原理,如何通过ajax实现下拉列表框之间的联动 解析xml 的方法 如何确定一个ArrayList中的元素是否存在于另一个ArrayList中1. for(Object obj:listA) if(!listB.contains(obj) return false; return true; SQL中,NVL和DECODE函数的用法1. NVL is used to check the NULL value.2. DECODE3. 说明下什么是代理模式/Tips/468254/Proxy-design-pattern-in-java1. Proxy Pattern2. Proxy design pattern allows you to create a wrapper class over real object.Wrapper class which is proxy,controls access to real object so in turn you can add extra functionalities to real object without changing real objects code.3. A remote proxy provides a local representative for an object in a different address space.Providing interface for remote resources such as web service or REST resources.4. A virtual proxy creates expensive object on demand.5. A protection proxy controls access to the original object.Protection proxies are useful when objects should have different access rights.6. A smart reference is a replacement for a bare pointer that performs additional actions when an object is accessed.7. Adding a thread-safe feature to an existing class without changing the existing classs code. 8. /articles/design-patterns-proxy The object being represented is external to the system. Objects need to be created on demand. Access control for the original object is required Added functionality is required when an object is accessed. 用COBOL写出一个判断并对变量赋值 写出获得链接的结构 接口和虚拟类的区别1. Abstract Classes: Classes which cannot be instantiated. This mean one cannot make a object of this class. Abstruct classes contains have one or more abstract methods, ie method body only no impemention.2. Interfaces: These are same as abstract classes only difference is we can only define definition and no implementation.3. when to use depends on various reasons. one being design choice. one reason for using abstruct classes is wen can code common functionality and force our developer to use id. jsp中 doPost 和 doGet 的区别1. GET : Query string or form data is simply appended to the URL as name-value pairs. Query length islimited(1KNB). Users can see data in address bar. not safe - A person standing over your shoulder can view your userid/pwd if submitted via GET invoke doGet(). support ASCII. easy to bookmark.2. POST : Form name-value pairs are sent in the body of the request, not in the URL itself. Query length is umlimited. Data hidden from users. safe - No one will be able to view what data is getting submitted invoke doPost() support ACSII + Binary. Hard to bookmark. switch-case中不能接收的数据类型 String是否有长度限制 左连接的SQL写法 Struts 的原理1.客户端发出一个指向servlet容器的请求(tomcat);2.这个请求会经过图中的几个过滤器,最后会到达FilterDispatcher过滤器。3.过滤器FilterDispatcher是struts2框架的心脏,在处理用户请求时,它和请求一起相互配合访问struts2 的底层框架结构。在web容器启动时,struts2框架会自动加载配置文件里相关参数,并转换成相应的类。 如:ConfigurationManager、ActionMapper和ObjectFactory。ConfigurationManager 存有配置文件的一 些基本信息,ActionMapper存有action的配置信息。在请求过程中所有的对象(Action,Results, Interceptors,等)都是通过ObjectFactory来创建的。过滤器会通过询问ActionMapper类来查找请求中 需要用到的Action。4.如果找到需要调用的Action,过滤器会把请求的处理交给ActionProxy。ActionProxy为Action的代理对象 。ActionProxy通过ConfigurationManager询问框架的配置文件,找到需要调用的Action类。5.ActionProxy创建一个ActionInvocation的实例。ActionInvocation在ActionProxy层之下,它表示了 Action的执行状态,或者说它控制的Action的执行步骤。它持有Action实例和所有的Interceptor。 6.ActionInvocation实例使用命名模式来调用,1. ActionInvocation初始化时,根据配置,加载Action相 关的所有Interceptor。2. 通过ActionInvocation.invoke方法调用Action实现时,执行Interceptor。在 调用Action的过程前后,涉及到相关拦截器(intercepetor)的调用。7. 一旦Action执行完毕,ActionInvocation负责根据struts.xml中的配置找到对应的返回结果。返回结果 通常是(但不总是,也可能是另外的一个Action链)一个需要被表示的JSP或者FreeMarker的模版。在表 示的过程中可以使用Struts2 框架中继承的标签。 项目中遇到的困难 Union 和 Union ALL的区别Union,对两个结果集进行并集操作,不包括重复行,同时进行默认规则的排序;Union All,对两个结果集进行并集操作,包括重复行,不进行排序;Intersect,对两个结果集进行交集操作,不包括重复行,同时进行默认规则的排序;Minus,对两个结果集进行差操作,不包括重复行,同时进行默认规则的排序。 JSP和SERVLET的关系 如何获得链接 如何实现多线程1. extends Thread2. implements Runnable3. Hashmap、Set的区别1. key-value, values can be replicated.2. value, value is exclusive.3. forward和redirect的区别1. forward-如果客户A向服务器B请求,服务器B处理了这个请求。struts的controller在服务器B处理请求的环节,调用action的具体execute方法。forward 发生在服务器内部, 在浏览器完全不知情的情况下发给了浏览器另外一个页面的response。2. redirect -如果客户A向服务器B请求,服务器B通知客户A向服务器C发出请求。客户A再想服务器C发出请求,服务器C才处理这个请求。例如你打开的网页,可是服务器会帮你链接到 ,这是一个redirect 的过程,地址栏将改变。struts的controller在服务器B通知客户A的环节,调用action的具体execute方法。HttpServletResponse.sendRedirect(String location)。 Xml相关的DTD和XSD有什么区别,用DTD如何定义attribute和sub-elements1. DTD(Documnet Type Definition)DTD即文档类型定义,是一种XML约束模式语言,是XML文件的验证机制,属于XML文件组成的一部分。DTD 是一种保证XML文档格式正确的有效方法,可以通过比较XML文档和DTD文件来看文档是否符合规范,元素和标签使用是否正确。 一个 DTD文档包含:元素的定义规则,元素间关系的定义规则,元素可使用的属性,可使用的实体或符号规则。DTD和XSD相比:DTD 是使用非 XML 语法编写的。DTD 不可扩展,不支持命名空间,只提供非常有限的数据类型 .2. XSD(XML Schemas Definition) XML Schema语言也就是XSD。XML Schema描述了XML文档的结构。 可以用一个指定的XML Schema来验证某个XML文档,以检查该XML文档是否符合其要求。文档设计者可以通过XML Schema指定一个XML文档所允许的结构和内容,并可据此检查一个XML文档是否是有效的。XML Schema本身是一个XML文档,它符合XML语法结构。可以用通用的XML解析器解析它。一个XML Schema会定义:文档中出现的元素、文档中出现的属性、子元素、子元素的数量、子元素的顺序、元素是否为空、元素和属性的数据类型、元素或属性的默认 和固定值。XSD是DTD替代者的原因,一是据将来的条件可扩展,二是比DTD丰富和有用,三是用XML书写,四是支持数据类型,五是支持命名空间。XML Schema的优点:1) XML Schema基于XML,没有专门的语法 2) XML Schema可以象其他XML文件一样解析和处理 3) XML Schema比DTD提供了更丰富的数据类型.4) XML Schema提供可扩充的数据模型。 5) XML Schema支持综合命名空间 6) XML Schema支持属性组。 JSP和Serlvet的区别1. jsp最终被编译器编译成servlet本质没有区别只是JSP易于显示内容 是为了弥补servlet的不足 JSP include有哪几种方式,有什么区别1. 2. 3. 4. 以下是对include 两种用法的区别主要有两个方面的不同;一:执行时间上: 是在翻译阶段执行 在请求处理阶段执行.二:引入内容的不同:引入静态文本(html,jsp),在JSP页面被转化成servlet之前和它融和到一起.引入执行页面或servlet所生成的应答文本. 作用域public, private, protected,以及不写时的区别?1. 作用域 当前类 同一package 子孙类 其他package public protected friendly private 2. 读取xml文件的方法有几种1)DOM(JAXP Crimson解析器) DOM是用与平台和语言无关的方式表示XML文档的官方W3C标准。DOM是以层次结构组织的节点或信息片断的集合。这个层次结构允许开发人员在树中寻找 特定信息。分析该结构通常需要加载整个文档和构造层次结构,然后才能做任何工作。由于它是基于信息层次的,因而DOM被认为是基于树或基于对象的。DOM 以及广义的基于树的处理具有几个优点。首先,由于树在内存中是持久的,因此可以修改它以便应用程序能对数据和结构作出更改。它还可以在任何时候在树中上下 导航,而不是像SAX那样是一次性的处理。DOM使用起来也要简单得多。 2)SAX SAX处理的优点非常类似于流媒体的优点。分析能够立即开始,而不是等待所有的数据被处理。而且,由于应用程序只是在读取数据时检查数据,因此不需要将数 据存储在内存中。这对于大型文档来说是个巨大的优点。事实上,应用程序甚至不必解析整个文档;它可以在某个条件得到满足时停止解析。一般来说,SAX还比 它的替代者DOM快许多。 选择DOM还是选择SAX? 对于需要自己编写代码来处理XML文档的开发人员来说, 选择DOM还是SAX解析模型是一个非常重要的设计决策。 DOM采用建立树形结构的方式访问XML文档,而SAX采用的事件模型。 DOM解析器把XML文档转化为一个包含其内容的树,并可以对树进行遍历。用DOM解析模型的优点是编程容易,开发人员只需要调用建树的指令,然后利用 navigation APIs访问所需的树节点来完成任务。可以很容易的添加和修改树中的元素。然而由于使用DOM解析器的时候需要处理整个XML文档,所以对性能和内存的要 求比较高,尤其是遇到很大的XML文件的时候。由于它的遍历能力,DOM解析器常用于XML文档需要频繁的改变的服务中。 SAX解析器采用了基于事件的模型,它在解析XML文档的时候可以触发一系列的事件,当发现给定的tag的时候,它可以激活一个回调方法,告诉该方法制定 的标签已经找到。SAX对内存的要求通常会比较低,因为它让开发人员自己来决定所要处理的tag.特别是当开发人员只需要处理文档中所包含的部分数据 时,SAX这种扩展能力得到了更好的体现。但用SAX解析器的时候编码工作会比较困难,而且很难同时访问同一个文档中的多处不同数据。 3)JDOM JDOM的目的是成为Java特定文档模型,它简化与XML的交互并且比使用DOM实现更快。由于是第一个Java特定模型,JDOM一直得到大力推广和 促进。正在考虑通过“Java规范请求JSR-102”将它最终用作“Java标准扩展”。从2000年初就已经开始了JDOM开发。 JDOM与DOM主要有两方面不同。首先,JDOM仅使用具体类而不使用接口。这在某些方面简化了API,但是也限制了灵活性。第二,API大量使用了Collections类,简化了那些已经熟悉这些类的Java开发者的使用。 JDOM文档声明其目的是“使用20%(或更少)的精力解决80%(或更多)Java/XML问题”(根据学习曲线假定为20%)。JDOM对于大多数 Java/XML应用程序来说当然是有用的,并且大多数开发者发现API比DOM容易理解得多。JDOM还包括对程序行为的相当广泛检查以防止用户做任何 在XML中无意义的事。然而,它仍需要您充分理解XML以便做一些超出基本的工作(或者甚至理解某些情况下的错误)。这也许是比学习DOM或JDOM接口 都更有意义的工作。 JDOM自身不包含解析器。它通常使用SAX2解析器来解析和验证输入XML文档(尽管它还可以将以前构造的DOM表示作为输入)。它包含一些转换器以将 JDOM表示输出成SAX2事件流、DOM模型或XML文本文档。JDOM是在Apache许可证变体下发布的开放源码。 4)DOM

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论