设为首页 加入收藏

TOP

阿里巴巴等名企Java笔试题摘选
2014-11-03 20:15:04 来源: 作者: 【 】 浏览:33
Tags:阿里巴巴 名企 Java 试题


A:Web Service就是为了使原来各孤立的站点之间的信息能够相互通信、共享而提出的一种接口。Web Service所使用的是Internet上统一、开放的标准,如HTTP、XML、SOAP(简单对象访问协议)、WSDL等,所以Web Service可以在任何支持这些标准的环境(Windows,Linux)中使用。注:SOAP协议(Simple Object Access Protocal,简单对象访问协议),它是一个用于分散和分布式环境下网络信息交换的基于XML的通讯协议。在此协议下,软件组件或应用程序能够通过标准的HTTP协议进行通讯。它的设计目标就是简单性和扩展性,这有助于大量异构程序和平台之间的互操作性,从而使存在的应用程序能够被广泛的用户访问。


优势:


缺点:


public class TestTryCatch {


public static void main(String[] args) {


System.out.println(“i的值为。。。”+new TestTryCatch().test());


}


private int test(){


int i = 1;


try {


return i;


}finally{


++i;


System.out.println(“finally is Executed…”);


}


}


}


A: i的值为 1


finally is Executed…


A:


A:java script 与Java 是两个公司开发的不同的两个产品。Java 是SUN 公司推


出的新一代面向对象的程序设计语言,特别适合于Internet 应用程序开发;而java script 是Netscape 公司的产品,其目的是为了扩展Netscape Navigator功能,而开发的一种可以嵌入Web 页面中的基于对象和事件驱动的解释性语言,它的前身是Live Script;而Java 的前身是Oak 语言。下面对两种语言间的异同作如下比较:


A:Collection FrameWork 如下:


Collection


├List


│├LinkedList


│├ArrayList


│└Vector


│ └Stack


└Set


Map


├Hashtable


├HashMap


└WeakHashMap


Collection 是最基本的集合接口,一个Collection 代表一组Object,即


Collection 的元素(Elements); Map 提供key 到value 的映射。


A:


File file = new File(“e:\\总结”);


File[] files = file.listFiles();


for(int i=0; i


if(files[i].isFile()) System.out.println(files[i]);


}


File file = new File(“e:\\总结”);


File[] files = file.listFiles();


for(int i=0; i


if(files[i].isDirectory()) System.out.println(files[i]);


}


System.out.println(new File(“d:\\t.txt”).exists());


//读文件:


FileInputStream fin = new FileInputStream(“e:\\tt.txt”);


byte[] bs = new byte[100];


while(true){


int len = fin.read(bs);


if(len <= 0)


break;


System.out.print(new String(bs,0,len));


}


fin.close();


//写文件:


FileWriter fw = new FileWriter(“e:\\test.txt”);


fw.write(“hello world!” + System.getProperty(“line.separator”));


fw.write(“你好!北京!”);


fw.close();


A:Java 中访问数据库的步骤如下:


1)注册驱动;


2)建立连接;


3)创建Statement;


4)执行sql 语句;


5)处理结果集(若sql 语句为查询语句);


6)关闭连接。


PreparedStatement 被创建时即指定了SQL 语句,通常用于执行多次结构相


同的SQL 语句。


A:Collections是个java.util下的类,它包含有各种有关集合操作的静态方法。


Collection是个java.util下的接口,它是各种集合结构的父接口。


A:Java语言中一个显著的特点就是引入了垃圾回收机制,使c++程序员最头疼的内存管理的问题迎刃而解,它使得Java程序员在编写程序的时候不再需要考虑内存管理。由于有个垃圾回收机制,Java中的对象不再有”作用域”的概念,只有对象的引用才有”作用域”。垃圾回收可以有效的防止内存泄露,有效的使用可以使用的内存。垃圾回收器通常是作为一个单独的低级别的线程运行,不可预知的情况下对内存堆中已经死亡的或者长时间没有使用的对象进行清楚和回收,程序员不能实时的调用垃圾回收器对某个对象或所有对象进行垃圾回收。回收机制有分代复制垃圾回收和标记垃圾回收,增量垃圾回收。


A:栈溢出是栈顶指针指向未知区域,可能造成系统崩溃,不仅仅指错数据而已。


abstract class Transaction implements Runnable { }


class Deposit extends Transaction {


protected void process() {


addAmount();


}


void undo(int i) {


System.out.println(“Undo”);


}


private void addAmount(){


}


}


What will happen if we attempted to compile the code Select the one right answer:


A:Vector是线程安全的,ArrayList不是。


A:RecordStore的中的记录的RecordID是递增无重复的,即使一条记录被删除,它的RecordID也不能被重复使用。另外RecordStore需要显示地调用closeRecordStore方法来持久化更改过的数据。


A:观察者模式又叫做发布-订阅(Publish/Subscribe)模式。观察者模式定义了一种一对多地依赖模式,让多个观察者同时监听某一个主题对象。这个主题对象在状态发生变化时,会通知所有的观察者对象,使它们能够自动更新自己。这里的主题对象就是指通知者,又叫做发布者。观察者又叫订阅者。在JDK中继承java.util.Observable类 可以实现观察者模式。


A:可以通过编译的,屏幕输出字符串 “Father”


A:


QUESTION NO: 1


  1、public class Test {


   public static void changeStr(String str){


   str=”welcome”;


   }


   public static void main(String[] args) {


   String str=”1234″;


   changeStr(str);


   System.out.println(str);


   }


  }


Please write the output result :



  QUESTION NO:2


  1. public class Test {


  2. static boolean foo(char c) {


  3. System.out.print(c);


  4. return true;


  5. }


  6. public static void main( String[] argv ) {


  7. int i =0;


  8. for ( foo(‘A’); foo(‘B’)&&(i<2); foo(‘C’)){


  9. i++ ;


  10. foo(‘D’);


  12. }


  13. }


  14. }


  What is the result


  A. ABDCBDCB


  B. ABCDABCD


  C. Compilation fails.


D. An exception is thrown at runtime.



  QUESTION NO: 3


  1. class A {


  2. protected int method1(int a, int b) { return 0; }


3. }



  Which two are valid in a class that extends class A (Choose two)


  A. public int method1(int a, int b) { return 0; }


  B. private int method1(int a, int b) { return 0; }


  C. private int method1(int a, long b) { return 0; }


  D. public short method1(int a, int b) { return 0; }


E. static protected int method1(int a, int b) { return 0; }



  QUESTION NO: 4


  1. public class Outer{


  2. public void someOuterMethod() {


  3. // Line 3


  4. }


  5. public class Inner{}


  6. public static void main( String[]argv ) {


  7. Outer o = new Outer();


  8. // Line 8


  9. }


  10.}


  Which instantiates an instance of Inner


  A. new Inner(); // At line 3


  B. new Inner(); // At line 8


  C. new o.Inner(); // At line 8


  D. new Outer.Inner(); // At line 8//new Outer().new Inner()



  QUESTION NO: 5


Which method is used by a servlet to place its session ID in a URL that is written to the servlet’s response output stream


  A. The encodeURL method of the HttpServletRequest interface.


  B. The encodeURL method of the HttpServletResponse interface.


  C. The rewriteURL method of the HttpServletRequest interface.


D. The rewriteURL method of the HttpServletResponse interface.



  QUESTION NO: 6


  Which of the following statements regarding the lifecycle of a session bean are correct



QUESTION NO: 7 描述Struts体系结构 对应各个部分的开发工作主要包括哪些



  QUESTION NO: 8 JSP有哪些内置对象和动作 它们的作用分别是什么


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇深圳八爪网络科技有限公司8aza软.. 下一篇美国FBI的面试题 IQ测试题~看你能..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: