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 EqTest();
}
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)CaseMatch(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
} }
java程序员培训班要多少钱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;
} }
A.Compile and run without error B.Compile 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);adChar();}
B.public void ioCall()throw IOException{ DataInputStream din = new DataInputStream(System.in);adChar();} C.public void ioCall()throws IOException{ DataInputStream din = new DataInputStream(System.in);adChar();}
D.public void ioCall throws IOException(){ DataInputStream din = new DataInputStream(System.in);adChar();
}
8.How do you force the garbage collector to run? A.()
B.()
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
C.Message passing
D.A headache
10.What's printed when the following program is executed: class PrintMe {
public void do(int character){
System.out.println(character+character);
}
public static void main(String args[]){
new PrintMe().do('A');
} }
A.AA
B.130(The ASCII value of A is 65)
C.Does not compile
11.What will be printed out if you attempt to compile and run the following code?
int i=9;switch(i){ default: System.out.println(“default”);case 0: System.out.println(“zero”);break;case 1: System.out.println(“one”);case 2: System.out.printl
n(“two”);}
A.default B.default, default clause not output displayed
12.What will be the result of attempting to compile and run the following code?
abstract class MineBase { abstract void amethod();static int i;} public class Mine extends MineBase { public static void main(String argv[]){ int[] ar=new int[5];for(i=0;i < ar.length;i++)System.out.println(ar[i]);} }
A.a sequence of 5 0's will be printed B.Error: ar is used before it is initialized C.Error: Mine must be declared abstract D.IndexOutOfBoundes Error
Part 2.The essential of jdbc 1.If you need to use a stored procedure with output parameters, which of the following statement type should be used to call the procedure?
A.Statement
B.PreparedStatement
C.CallableStatement
2.Which of the following will not cause a JDBC driver to be loaded and registered with the DriverManager?
A.Class.forName(driverString);
B.new DriverClass();
C.Include driver name in jdbc.drivers system property
D.None of the above 3.From which object do you ask for DatabaseMetaData?
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论