java 银行笔试题库_Java笔试题库及其答案.doc

1) 在JAVA中,要判断D盘下是否存在文件abc.txt,应该使用以下( )判断语句。(选择一项)

a) if(new File(“d:abc.txt”) .exists() = =1)

b) if(File.exists(“d:abc.txt”) = =1)

c) if(new File(“d:/abc.txt”) .exists( ) )

d) if(File.exists(“d:/abc.txt))

答案:C

2) 在java中,()对象可以使用键/值的形式保存数据。 (选择一项)

a)ArrayList

b) HashSet

c) HashMap

d) LinkedList

答案:C

3) 给定java代码,如下:

public byte count(byte b1,byte b2){

return______;

}

要使用这段代码能够编译成功,横线处可以填入() 。 (选择一项)

(byte) (b1-b2)

(byte) b1-b2

c) b1-b2

d) (byte) b1/b2

答案:A

4) 在Java中,在包com.db下定义一个类,要让包com.util下的所有类都可以访问这个类,这个类必须定义为()。 (选择一项)

a)protected

b)private

c)public

d)friendly

答案:C

5) 在Java中,下列()语句不能通过编译。 (选择一项)

a) String s= “join”+ “was”+ “here”;

b) String s= “join”+3;

c) int a= 3+5

d) float f=5+5.5;

答案:D

6)给定java代码如下,运行时,会产生()类型的异常。(选择一项)

String s=null;

s.concat(“abc”);

a)ArithmeticException

b)NullPointerException

c)IOException

d)EOFException

答案:B

7) 给定如下java代码,编译运行之后,将会输出()。

public class Test{

public static void main(String args[]){

int a=5;

System.out.println(a%2==1) ?(a+1) /2:a/2) ;

}

} (选择一项)

a)1

b)2

c)2.5

d)3

答案:D

8) java程序中,main方法的格式正确的是()。 (选择一项)

a)static void main(String[] args)

b)public void main(String[] args)

c)public static void main(String[]s)

d)public static void main(String[] args)

答案:D

9) 以下Java语句中,String str = “123456789”;str =str.subString(1,3);执行后str中的值为。(选择一项)

a) “23”

b) “123”

c) “12”

d) “234”

答案:A

10) 给定如下java代码,编译运行时,结果是()。 (选择一项)

public class Test{

public static void main (String args[]) {

for (int i=0;i<3; i++) {

System.out.print(i) ;

}

System.out.print(i) ;

}

}

a) 编译时报错

b) 正确运行,输出012

c) 正确运行,输出123

d) 正确运行,输出0123

答案:A

11) Java语言中,String str=”123456789”,System.out.println(str.indexOf(“5”)),输出结果为()。(选择一项)

a) 6

b) 5

c) 4

d) -1

答案:C

12)给定某java程序的main方法,如下:

pub

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值