亚信笔试题(翻译后的) 联系客服

发布时间 : 星期日 文章亚信笔试题(翻译后的)更新完毕开始阅读a50f636958fafab069dc021d

一、选择题

1、Given the following class,which statements can be inserted at position 1 without causing the code to fail compilation? 答案是

//给出如下类,选项中那句话插入位置1不会造成编译错误的是哪一项? Public class Q6db8{ int a ; int b=0; static int c; public void m(){ int d; int e=0; //Position 1 }

} A、 a++; B、 b++; C、 c++; D、 d++; E、 e++;

2、Consider the following line of code:int x[]=new int[25];After execution,which statement or statemensts are true? 答案是

//思考下面一行代码,执行过后,选项中哪一项或哪些说法是正确的? A、 x[24] is 0.

B、 x[24] is undefined C、 x[25] is 0. D、 x[0] is null. E、 x.length is 25.

3、Consider the following application: 1. class Q6{ 2. public static void main(String args[]){ 3 Holder h=new Holder(); 4 h.held=100; 5 h.bump(h); 6 System.out.println(h.held); 7. } 8. }

9.

10. class Hoder{ 11. public int held;

12 public void bump(Holder theHolder){theHolder.held++;} 13. } What value is printed out at line 6? 答案是

//思考如下应用,第六行的输出结果是什么?

A、0 B、1 C、100 D、101

4、The demonstrate(s) belongs to “has a” relationship? 答案是 //选项中哪一项或哪些项是has-a关系?

A、 public interface Person{} public class Employee extends Person{} B、 public interface Shape{} public inter face Recrandle extends Shape{} C、 public interface Colorable{} public calss Shape implements Colorable{} D、 public class Species{} public class Animal{private Species species}

E、 interface Componet{} class Container implements Component{private Component[]

children;}

5、Consider the following code:

//思考如下代码 1.for(int i=0;i<2;i++){

2. for(int j=0;j<3;j++){ 3. if(i==j){ 4. continue; 5. } 6 System.out.println(“i= ”+i+”j= ”+j);. 7. } 8.}

Which lines would be part of the output? 答案是:

//那一行是输出的一部分

a. i=0 j=0 b. i=0 j=1 c. i=0 j=2 d. i=1 j=o e. i=1 j=1 f. i=1 j=2

6、Consider the following class hierarchy and code fragments: //看下面的类的结构和代码块 Java.lang.Exception \ Java.io.IOException / \ Java.io.StreamCorruptedException java.net.MalformedURLException

1. try{

2. URL u=new URL(s);//assume s is previously defined 3. Object o=in.readObject();//in is an ObjectInputStream 4. System.out.println(“Success”); 5. }

6. catch(MalformedURLException e){

7. System.out.println(“Bad URL”); 8. }

9. catch(StreamCorruptedException e){ 10. System.out.println(“Bad file contents”); 11. }

12. catch(Exception e){

13. System.out.println(“General exception”); 14. }

15. finally{

16. System.out.println(“doing finally part”); 17. }

18. System.out.println(“Carrying on”);

What lines are output if the method at line 2 throws a Malformed URL Exception? 答案是 //如果在第2行抛出一个Malformed URL Exception 将输出什么? A、 Success B、 Bad URL

C、 Bad file contents D、 General exception E、 Doing finally part F、 Carrying on

7、1. public class Text extends Base 2. public Test(int j){ 3. }

4. public Test(int j,int k){ 5. super(j,k); 6. } 7.}

Which of the following are legitimate calls to construct instance of Test class? 答案是 //下列哪些项是对test类的构造器实例的合法调用? A、 Test t=new Test(); B、 Test t=new Test(1); C、 Test t=new Test(1,2); D、 Test t=new Test(1,2,3);

E、 Test t=(new Base()).new Test(1);

8、Which one statement is true about the code fragment below? 答案是 //在下面的代码片段中,那一种陈述是正确的 1. String s=”abcde”; 2. StringBuffer s1=new StringBuffer(“abcde”); 3.if(s.equals(s1)) 4. s1=null; 5. if(s1.equals(s)) 6.s=null; A、Compilation fails at line 1,because the String constructor must be called explicitly.

//在第一行编译失败,因为字符串构造器必须有明确的命名

B、Compilation fails at line 3,because s and s1 have different types. //在第3行编译失败,因为s和s1 是不同的类型 C、Compilation succeeds.During execution,an exception is thrown at line 3. //编译成功,在执行期间,在第三行抛出一个异常 D、Compilation succeeds.During execution,an exception is thrown at line 5. //编译成功,在执行期间,在第五行抛出一个异常 E、Compilation succeeds.No exception is thrown during execution. //编译成功,在执行期间没有异常抛出

9、Which would be most suitable for storing data elements that must not appear in the store more than once, if searching is not a priority? 答案是

//下列哪些对象最适合用于存放在结构中最多只出现一次的数据,如果查找是没有先后顺序的? A、Collection B、List C、Set D、Map E、Vector

10、Given that Thing is a class,how many objects and reference variables are created by the following code? 答案是 //假如Thing是一个类,在接下来的代码中友多少对象和引用变量将被创建 Thing item,stuff; Item=new Object(); Thing entity=new Object(); A、 One object is created;

B、 Two objects are created. C、 Three objects are created.

D、 One reference variable is created. E、 Two reference variables are created F、 Three reference variables are created

11.Examine the structure of the EMPLOYESS table:

查看雇员表的架构: EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25)

//小写

employee_id number primary key, first_name varchar2(25), last_name varchar2(25) Which three statements insert a row into the table ?(choose three)

下面那三个语句能向雇员表中插入一行?(请选择三个正确答案)( ) A.insert into employees values(null,'john','smith');

B.insert into emoloyees (first_name,last_name) values('john''smith') C.insert into employees values('1000','jhon',null);

D.insert into emoloyees(first_name,last_name,employee_id)values (1000,'john','smith');

E.insert into employees(employee_id)values(1000);

F.insert into Employees(employee_id,first_name,last_name)values(1000,'jhon','');