第一篇: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)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;
} }
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);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
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.println(“two”);}
A.default B.default, zero C.error default clause not defined D.no 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?
A.Connection
B.ResultSet
C.DriverManager
D.Driver
4.If one intends to work with a ResultSet, which of these PreparedStatement methods will not work?
A.execute()
B.executeQuery()
C.executeUpdate()
5.Can a ResultSet be reliably returned from a method that creates a Statement and executes a query?
A.Yes
B.No
6.How can I use JDBC to create a database?
A.Include create=true at end of JDBC URL
B.Execute “CREATE DATABASE jGuru” SQL statement
C.Execute “STRSQL” and “CREATE COLLECTION jGuru” SQL statements
D.Database creation is DBMS specific
7.Which character is used to represent an input parameter in a CallableStatement?
A.%
B.*
C.?
D.#
8.Which one of the following will not get the data from the first column of ResultSet rs, returned from executing the following SQL statement: SELECT name, rank, serialNo FROM employee.A.rs.getString(0);
B.rs.getString(“name”);
C.rs.getString(1);
9.Which of the following can you do with a JDBC 2.0 database driver that you cannot with a JDBC 1.x driver?
A.Batch multiple statements, to be sent to the database together
B.Scroll through result sets bi-directionally
C.Work with SQL3 data types directly
D.All of the above
10.Which class contains the transaction control methods setAutoCommit, commit, and rollback?
A.Connection
B.Statement
C.ResultSet
Part 3.The essential of xml
1.There is a way of describing XML data, how?
A.XML uses XSL to describe data
B.XML uses a description node to describe data C.XML uses a DTD to describe the data.D.XML uses a SCHEMA to describe the data.2.What is the correct syntax of the declaration which defines the XML version?
A. B. C.
3.Which one is this a correct XML document? A.
第二篇:Java程序员岗前测试
软件企业程序员入职参考测试题
班级_________
姓名_________(共61题,对52%即通过,时间61分钟)1 下列哪些是JAVA语言中合法的标识符:
A
fieldname B
super C
3number D #number E $number 下面那些是JAVA的关键字:
A final B Abstract C
Long D
static 下面代码会输出什么结果:
public class Test{ public static void main(String[] args){
Test o = new Test();
o.amethod();} public void amethod(){ int oi = 012;System.out.println(oi);} } A B 012 C D 10.0 在编译和运行下面代码时会发生什么:
public class Test{ public static void main(String[] args){
int[] i = new int[5];
System.out.println(i[5]);} } A 编译错误 B 运行时错误 C 输出0 D 输出“null” 下列哪些数组的声明或初始化是正确的:
A
String srt[];B String str[5] = new String[5];
C String str[] =
new
String[]{“s1”,”s2”,”s3”,”s4”,”s5”};
D String str[] = {“s1”,”s2”,”s3”,”s4”,”s5”};下列代码会输出什么:
public class Test{ static int j =20;public static void main(String[] args){
int i =10;
Test p =new Test();p.amethod(i);System.out.println(i);System.out.println(j);}
public void amethod(int x){ x=x*2;j=j*2;} } A
编译错误 B 20 和 40 C 10 和 40 D 10 和 20 编译和运行以下代码会发生什么:
public class Test{
public static void main(String[] args){
System.out.println(5 | 7);} }
A 编译错误 B 运行期异常 C 输出5 D 输出7 E 输出2 下列哪个语句是错误的:
A
float f = 11.1;
B double d = 5.3E12;C double d = 3.14159;D double d = 3.14D;下面代码会输出什么:
int i = 16;int j = 17;
System.out.println(i >> 1);System.out.println(j >> 1);A 8和8 B 7和7 C 8和9 D 7和8 10 以下代码会输出什么:
System.out.println(010 | 4);A 14 B 0 C 6 D 12 请看下列代码:
String s = “hello”;String t = “hello”;
Char c[] = {„h‟,‟e‟,‟l‟,‟l‟,‟o‟};选项中哪些返回true: A s.equals(t);B t.equals(c);C s == t;D t.equals(new String(“hello”));E t == c;请看下列代码:
class Test{ public static void main(String[] args){
int s = 10;
s >>= 10;
System.out.println(“s=” + s);
} } 选择正确的答案: A 编译错误 B 运行错误 C 0 D 1 请看以下代码:
public static void main(String[] args){ Float f = new Float(4.2f);Float c;Double d = new Double(4.2);float f1 = 4.2f;c = f;} 下列哪些是正确的: A f.equals(d);B c == f;C c == d;D c.equals(f);下面的代码哪些是正确的定义了一个抽象类:
A class Test{
abstract void grow1();} B abstract Test{
abstract void grow1();
} C class abstract Test{ abstract void grow1();} D abstract class Test{ abstract void grow1();} E abstract class Test{ abstract void grow1(){ }
} 下面哪些是JAVA中合法的修饰符:
A private B public C protected D protect E
friend 编译和运行以下代码时会发生什么:
public class Test{ private int i;public static void main(String[] args){
Test s = new Test();
s.amethod();
}
public static void amethod(){ System.out.println(i);} }
A 输出0 B 没有输出 C 编译错误 D 运行错误 试图编译和运行以下代码时会发生什么:
class Test{ protected int i=99;}
public class Ab{ private int i = 1;public static void main(String[] args){ Ab a = new Ab();a.hallow();} abstract void hallow(){ System.out.println(i);} } A 编译错误
B 编译通过并输出99 C 编译通过并输出1 D 编译通过但运行时没有输出 试图编译和在控制台上输入java Test hello there运行以下代码时会发生什么: public class Test{ String[] myArg;public static void main(String[] args){
myArg = args;} public void amethod(){ System.out.println(args[1]);} } A 编译错误
B 编译通过并输出hello C 编译通过并输出there D 以上都不对 以下代码有什么错误?选出所有正确的答案:
final class Test{ private int a = 1;int b = 2;} class Second extends Test{ public void method(){ System.out.println(a + b);} } A println方法应该传入String类型的参数
B a是私有的,所以除了Test类以外别的类不能访问
C Second不能继承Test D
final不是一个关键字下列哪些选项可以放置在×××处:
public class OuterClass{ private String s = “I am outer class member variable”;
class InnerClass{
private String s1 = “I am inner class variable”;
public void innerMethod(){
System.out.println(s);
System.out.println(s1);}
} //inner class
public static void outerMethod(){
//×××
inner.innerMethod();}
}//outerclass
A OuterClass.InnerClass inner = new OuterClass().new InnerClass();
B InnerClass inner = new InnerClass();C new InnerClass();D 以上选项都不对编译和运行以下代码会发生什么:
public class Test{ public static void main(String[] args){
Test h = new Test();}
protected Test(){ for(int i=0;i<10;i++){
System.out.println(i);
} } }
A 编译错误:构造方法不能声明成protected B 运行时错误:构造方法不能声明成protected C 编译通过并输出0到10 D 编译通过并输出0到9 编译和运行以下代码会发生什么:
class Test{ public static void main(String[] args){ try{
byte x = 5;
byte y = x *2;System.out.println(y);}catch(Exception e){ System.out.println(“exception”);}//catch }//main }//class Test A 编译错误
B 输出exception C 5 D 10 E 15 F 20 G 25 下列哪些语句在编译时不会有警告或错误:
A float f = 1.3;B char c = “a”;C byte b = 257;D boolean b = null;E int i = 10;一个类中带有一个成员变量,如果不希望这个成员变量被除了自己之外的其他任何类访问,那么这个变量应该使用哪个修饰符修饰: A private B public C transient D final E abstract 一个整型变量x的二进制值为:1001 1100,如下语句执行之后z的值是: int y = 1 << 7;int z = x & y;A 1000 0001 B 1000 0000 C 0000 0001 D 1001 1101 E 1001 1100 下面程序运行的时候将会产生哪些输出:
public class Test {
public static void main(String args[]){
double d =-2.9;
int i =(int)d;
i *=(int)Math.ceil(d);
i *=(int)Math.abs(d);
System.out.println(i);
} }
A 12 B 18 C 8 D 12 E 27 请看下面的代码:
void looper(){
int x = 0;
one:
while(x < 10){
two:
System.out.println(++x);
if(x > 3)
break two;
} }
选择所有有效的答案:
A 代码编译成功 B 代码编译错误
C 代码执行后将会打印处数字0 D 将会打印数字1和2 E 将会打印数字3
看下面的代码,将会打印出什么结果:
int m = 0;
while(m++ < 2)
System.out.println(m);
A 0 B 1 C 2 D 3
E 什么都没有,而且会产生一个异常错误 29 查看如下申明:
char[] c = new char[100];c[50]的内容是什么: A 50 B 49 C 'u0000' D 'u0020' E 在赋值之前是null 以下代码的输出结果是什么:
Boolean b1 = new Boolean(true);Boolean b2 = new Boolean(true);if(b1 == b2)
if(b1.equals(b2))
System.out.println(“a”);
else
System.out.println(“b”);
else
if(b1.equals(b2))
System.out.println(“c”);
else
System.out.println(“d”);
选出正确的答案: A a B b C c D d
给出以下代码:
switch(m){ case 0:System.out.println(“0”);break;case 1:System.out.println(“1”);break;case 2:System.out.println(“2”);break;case 3:System.out.println(“3”);
break;default:System.out.println(“other”);}
当m是何值时会输出2,选出所有可能的答案:A 0 B 1 C 2 D 3 E 4 F 以上都不对
参考以下代码块
outer: for(int i = 1;i <3;i++)
{ inner: for(j = 1;j < 3;j++)
{ if(j==2)
continue outer;
System.out.println(“i = ” +i “, j = ” + j);
}
}
下列哪些会被输出到控制台 A i = 1, j = 1 B i = 1, j = 2 C i = 1, j = 3 D i = 2, j = 1 E i = 2, j = 2
查看以下代码:
class Test{ public static void main(String[] args){
try{
return;
}catch(Exception e){
System.out.println(“Exception”);
}finally{ System.out.println(“Finally”);} } }
会发生什么:
A 编译错误,main方法不能返回任何值 B 打印出“Exception”
C 打印出“Exception”和“Finally” D 打印出“Finally”
如果s1的定义为:String s1 = “phenobarbital”;
那么执行如下代码后s2的值是什么: String s2 = s1.substring(3, 5);A null B “eno” C “enoba” D “no”
看如下代码:
class A {}
class B extends A {} class C extends A {} public class Q3ae4 {
public static void main(String args[]){
A x = new A();
B y = new B();
C z = new C();
// insert statement here
} } 在insert statement here处插入如下选项中的代码,哪些代码会引起程序运行产生runtime异常: A x = y;B z = x;; C y =(B)x。D z =(C)y;; E y =(A)y;;
查看如下代码:
1: public void aMethod { 2: 3:
if(Condition){ 4:
5:
} 6: 7: } 如果上面代码中的Condition为true应该抛出MyException类型的异常,那么哪些答案的描述是正确的:
A在第4行添加throw new Exception();
B在第4行添加throws new MyException()。C在第6行添加throw new MyException(); D在第2行添加throws new Exception(); E 在第1行添加throws MyException
译和运行以下代码时会发生什么:
public class Test{
static void throwMethod(){
System.out.println(“inside ThrowMethod”);
throw new IllegalAccessException(“demo”);
} //throwMethod public static void main(String[] args){ try{
throwMethod();}catch(IllegalAccessException e){ System.out.println(“Caught “ + e);
}//catch }//main }
选出正确的答案 A 编译错误。B 运行时错误
C 编译通过,但没输出
D 输出Inside throwMethod 接着输出caught: java.lang.IllegalAccessException:demo
给出以下代码:
public static void main(String[] args){ int i = 1;int j = 10;
do{ if(i >j)
continue;
j--;}while(++i < 6);
System.out.println(“i=” +i+” j=” + j);
}//main
下列哪些会被输出: A i=4 j=5 B i=5 j=6 C i=5 j=5 D i=4 j=6 E i=6 j=5
39当运行下面程序时会发生什么: class Tester{ int var;Tester(double var){
this.var =(int)var;
}
Tester(int var){ this(“hello”);}
Tester(String s){ this();System.out.println(s);}
Tester(){ System.out.println(“good-bye”);}
public static void main(String[] args){ Tester t = new Tester(5);} }
选出所有正确答案 A 没有任何输出 B 输出“hello” C 输出5 D 输出“hello”和”good-bye” E 输出“good-bye”和”hello”
40给出下列代码 public class Base{ int w,x,y,z;public Base(int a,int b){
x = a;
y = b;} public Base(int a,int b,int c,int d){ //设置x = a;y = b w =d;z =c;} } 在//设置x = a;y = b处可以添加什么代码,选出所有正确的答案:
A Base(a,b);B x =a,y =b;C x =a;y=b;D this(a,b);41 如果你试图编译以下代码并执行B类中的main方法时会发生什么,选择唯一的正确答案
class A {
int i;
A(int i){
this.i = i * 2;
} }
class B extends A {
public static void main(String[] args){
B b = new B(2);
}
B(int i){
System.out.println(i);
} } A 实例变量i被设置为4 B 实例变量i被设置为2 C 实例变量i被设置为0
D 编译出错
42编译和运行以下代码会发生什么
1.class A {
2.public int i=5;
3.A(int initi){ i = initi;}
4.public static void main(String[] args){ 5.final A theA = new A(10);6.theA.i = 15;
7.System.out.println(theA.i);8.} 9.}
A 第六行编译出错 B 程序输出”5”;C 程序输出”10”;D 程序输出”15”;
43关于try、catch、finally块,下列描述正确的是:
A try块后面必须总是跟着catch块
B try块后面可以跟catch块或者finally块,也可以两者都有。
C catch必须总是和try块关联。
D 如果没有try块的话,finally块永远不可以单独出现。
E 上面没有一个是正确的
44查看下面的代码,编译个运行该代码将会产生什么结果:
public static void main(String args[]){ int a = 5;
System.out.println(cube(a));}
int cube(int theNum){
return theNum * theNum * theNum;}
A 因为cube在java.lang.Math类中已经定义了,所以编译错误
B 因为cube不是静态类型的,所以编译错误。C 编译成功,但是会抛出算术异常 正常运行,打印出”125”
D 正常运行,打印出”125”
45定义一个八进制的值17,下面哪些方法是正确的:
A private final int theNumber = 0x17;B private final int theNumber = 017;C public int theNumber = 017;
D public int theNumber =(octal)17;E
public int THE_NUMBER = 017;
给定如下接口:
interface A {
int method1(int i);
int method2(int j);} 下面哪些类实现了这个接口而且不是抽象类: A class B implements A {
int method1(){ }
int method2(){ } }
B class B {
int method1(int i){ }
int method2(int j){ } }
C class B implements A {
int method1(int i){ }
int method2(int j){ } }。
D class B extends A {
int method1(int i){ }
int method2(int j){ } }
E class B implements A {
int method2(int j){ }
int method1(int i){ } }。
编译和运行以下代码时会发生什么:
class Mystery{
String s;
public static void main(String[] args){
Mystery m = new Mystery();
m.go();}//main void Mystery(){ s = “constructor”;} void go(){ System.out.println(s);} }//Mystery 选出正确答案 A 编译错误
B 运行时抛出异常 C 运行时没有任何输出 D 运行时输出”constructor” E 运行时输出”null”
48编译以下代码时会发生什么错误:
class A{ private int x;public static void main(String[] args){
new B();}
class B{ B(){
System.out.println(x);
} } }
A 类B试图访问它外部类A里面的私有变量
B 类A在没有创建A的实例前试图创建一个类B的实例。
C 类B的构造方法必须被申明成public
49试图编译和运行以下代码时会发生什么
1.class Fish { }
2.class Shark extends Fish { } 3.class Guppy extends Fish { } 4.5.public class Ocean {
6.public static void main(String[] args){ 7.Fish f = new Shark();8.Guppy g =(Guppy)f;9.}
10.}
A 第七行编译出错.B 第八行编译出错
C
第七行运行时抛出异常 D
第八行运行时抛出异常 E
程序正确运行
如果下面的代码段被成功编译和执行,将会显示什么结果:
class Test{
public static void main(String [] args){
Base b = new Subclass();
System.out.println(b.x);
System.out.println(b.method());
} } class Base{
int x = 2;
int method(){
return x;
} }
class Subclass extends Base{
int x = 3;
int method(){
return x;
} }
A 什么都没有,因为对象b没有使用正确的方法构造对象,所以代码编译错误 B 2 3。C 2 2 D 3 3 E 3 2
51下面哪些方法申明能够被放在注释处,选出所有正确的答案
class Base{ public void aMethod(int i){} } public class Scope extends Base{ public static void main(String[] args){} //注释 } A void aMethod(int i)throws Exception{} B void aMethod(long i)throws Exception{} C void aMethod(long i){} D public void aMethod(int i)throws Exception
52给出以下代码:
public class Test{ public static void test(){
this.print();} public static void print(){ System.out.println(“Test”);}
public static void main(String[] args){ test();}
}
编译和运行这个类时会发生什么: A 输出Test
B 运行时异常,因为对象没有创建出来 C 没有任何输出
D 运行时异常,因为找不到test方法
E 运行时异常,因为this变量只能在一个实例中使用
F 编译错误,因为在test方法中使用this变量。
53给出以下代码:
class Happy{ public int getLength(){
System.out.println(“int version”);
return 1;} }
class Life extends Happy{ public long getLength(){
System.out.println(“long version”);
return 1;}
public static void main(String[] args){ Happy e = new Life();e.getLength();} }
下列正确的是: A 输出int version B 输出 long version C 编译错误 D 运行期异常 E 没有输出
查看下面的代码:
class Tree{}
class Pine extends Tree{} class Oak extends Tree{} public class Forest
{ public static void main(String[] args)
{ Tree tree = new Pine();
if(tree instanceof Pine)
System.out.println(“Pine”);
if(tree instanceof Tree)
System.out.println(“Tree”);
if(tree instanceof Oak)
System.out.println(“Oak”);
else System.out.println(“Oops”);
} } 选择所有会被打印出来的内容: A Pine。B Tree。C Forest D Oops。
E 没有打印任何内容
55什么情况下一个线程会停止执行
a)一个具有更高优先级的线程开始执行的时候 b)线程的wait方法被调用 c)线程的yield方法被调用 d)线程pause方法被调用 e)线程的sleep方法被调用
给定下面的类:
class Counter {
public int startHere = 1;
public int endHere = 100;
public static void main(String[] args){
new Counter().go();
}
void go(){
// A
Thread t = new Thread(a);
t.start();
} } 哪几个答案可以被放在//A处,使得程序执行的时候能够从startHere数到endHere: A.Runnable a = new Runnable(){
public void run(){
for(int i = startHere;i <= endHere;i++){
System.out.println(i);
}
} }。
B.a implements Runnable {
public void run(){
for(int i = startHere;i <= endHere;i++){
System.out.println(i);
}
} };
C.Thread a = new Thread(){
public void run(){
for(int i = startHere;i <= endHere;i++){
System.out.println(i);
}
} }。
57试图编译和运行以下代码时会发生什么? class Test implements Runnable{ int i = 0;public int run(){
while(true){
i++;System.out.println(“i=”+i);
} } }
选出正确的答案
A 编译成功,run方法打印出i的值
B 编译成功,调用start方法后打印出i的值 C 编译错误
D 编译错误,因为while的参数不能是true
给出下面代码,会输出什么结果? class ValHold{ public int i = 10;}
public class ObParm{
public static void main(String argv[]){ ObParm o = new ObParm();o.amethod();}
public void amethod(){ int i = 99;
ValHold v = new ValHold();v.i=30;
another(v,i);
System.out.println(v.i);}//End of amethod public void another(ValHold v, int i){ i=0;v.i = 20;ValHold vh = new ValHold();v = vh;System.out.println(v.i+ “ ”+i);}//End of another } A 10,0, 30 B 20,0,30 C 20,99,30 D 10,0,20
public class test{ private static int j = 0;private static boolean methodB(int k){
j += k;
return true;
} public static void methodA(int i){
boolean b;
b = i < 10 | methodB(4);
b = i < 10 | methodB(8);} public static void main(String[] args){ methodA(0);System.out.println(j);} }
编译和运行时会发生什么?
A 输出“0” B 输出 “4” C 输出 “8” D 输出 “12” E 编译错误
class Test {
public static void main(String[] args){
Thread t = new Thread(new RunHandler());
t.start();
} } 下列选项中哪些是正确的:
A RunHandler 必须实现.Runnable接口 B RunHandler 必须继承Thread类
C
RunHandler必须提供一个run(),它的访问权限应该是public,返回类型是void
D RunHandler 必须提供一个init方法
61查看以下代码,编译和运行时会发生什么 public class Bground extends Thread{ public static void main(String argv[]){
Bground b = new Bground();
b.run();
}
public void start(){
for(int i = 0;i <10;i++){
System.out.println(“Value of i = ” + i);
}
} }
A 编译错误 B 运行错误
C 编译成功,输出0到9 D 编译成功,但没输出。
62在下面代码的注释处加入什么代码会输出“running” class Test implements Runnable{ public static void main(String[] args){
Test rt = new Test();
Thread t = new Thread(rt);//注释
}
public void run(){ System.out.println(“running”);}
void go(){ start(1);}
void start(int i){ } }
A System.out.println(“running”);B rt.start();C rt.go();D rt.start(1);
第三篇:JAVA程序员笔试题目(模版)
JAVA程序员笔试题目
1、有一个Vector对象,其中每一个元素都是一个String对象,请用For循环或者While循环输出Vector中的元素,要求格式为:“第i个元素为:aaa”
2、答:
3、Iterator it=Vector.iterat();
4、While(it.hasNext()){
5、String temp=(String)it.next();System.out.print(第一个元素为:);System.out.println(temp);6、7、}
8、Jsp有哪些内置对象,作用分别是什么?
9、答:request,response,pageContext,session,application,out.config,page,exception等
10、在try {}里面有一个return语句,那么紧跟在try{}后的finally{}里面的 code是否会被执行,是什么时候执行,在return之前还是之后。答:
11、面向对象的基本特征是什么?
12、答:继承,封装,多态,13、页面之间传递参数的方法有哪些?
14、答:利用request,pageContext,session,application,cookie对象都可以
15、Servlet中什么时候调用doGet()和doPost()?这两种方法有什么不同?
16、答:当表单是用get方法提交时,调用doGet(),反之调用doPost();
17、页面中有一个名称为unitprice的type=text的对象。要求输入的数据不能为空,写一个函数实现该功能,如果为空是给出提示。(用JavaScript语言写出)答: