JAVA程序员基本测试题目

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

JAVA程序员基本测试题目

第一篇:JAVA程序员基本测试题目

PART 1:The essential of java 1.Given the following code, what test would you need to put in place of the comment line? //place test here to result in an output of the string Equal public class EqTest{ public static void main(String argv[]){

EqTest e=new EqT est();

}

EqTest(){

String s=“Java”;

String s2=“java”;

//place test here {

System.out.println(“Equal”);

}else

{

System.out.println(“Not equal”);

}

} }

A)if(s==s2)B)if(s.equals(s2)C)if(s.equalsIgnoreCase(s2))D)if(s. noCaseMatch(s2))

2.Given the following code how could you invoke the Base constructor that will print out the string “base constructor”;

class Base{

Base(int i){ System.out.println(“base constructor”);

}

Base(){

} }

public class Sup extends Base{

public static void main(String argv[]){ Sup s= new

Sup();//One

}

Sup()

{ //Two

}

public void derived()

{ //Three

} }

A.On the line After //One put Base(10);

B.On the line After //One put super(10);

C.On the line After //Two put super(10);

D.On the line After //Three put super(10);

3.What is the value of seasons.length for the following array?

String[] seasons = {“winter”, “spring”, “summer”, “fall”, };

A.undefined

B.3

C.4

D.5

4.When you use the new keyword to create an object, where is it created? A.Heap

B.Garbage collector

C.Queue

D.Stack

5.What will happen if you attempt to compile and run the following code?

class Base {} class Sub extends Base {} class Sub2 extends Base {} public class CEx{

public static void main(String argv[]){ Base b=new Base();Sub s=(Sub)b;

} }

pile and run without error

pile time Exception

C.Runtime Exception

6.An overridden method can be in the same class.A.True

B.False

7.Given the following code

import java.io.*;public class Th{

public static void main(String argv[]){ Th t = new Th();t.amethod();

}

public void amethod(){ try{

ioCall();}catch(IOException ioe){}

} } What code would be most likely for the body of the ioCall method A.public void ioCall(){ DataInputStream din = new DataInputStream(System.in);din.readChar();}

B.public void ioCall()throw IOException{ DataInputStream din = new DataInputStream(System.in);din.readChar();}

C.public void ioCall()throws IOException{ DataInputStream din = new DataInputStream(System.in);din.readChar();}

D.public void ioCall throws IOException(){ DataInputStream din = new DataInputStream(System.in);din.readChar();

}

8.How do you force the garbage collector to run? A.Call System.gc()

B.Call Runtime.gc()

C.Either A or B

D.There is nothing you can do

9.When multiple methods exist within the same class with different method signatures, this is known as what? A.Method overloading

B.Overriding methods

相关文档
最新文档