达内第一次JAVA考试题

2018-12-23 23:32

1.

关于下列代码说法不正确的是:() 10. interface Foo { 11. int bar(); 12. } 13.

14. public class Beta { 15.

16. class A implements Foo { 17. public int bar() { return 1; } 18. } 19.

20. public int fubar( Foo foo) { return foo.bar(); } 21.

22. public void testFoo() { 23.

24. class A implements Foo { 25. public int bar() { return 2; } 26. } 27.

28. System.out.println( fubar( new A())); 29. } 30.

31. public static void main( String[] argv) { 32. new Beta().testFoo(); 33. } 34. } A. 编译错误 B.

运行代码输出:2 C.

如果删除16,17,18行,运行代码应然输出:2 D.

如果删除24,25,26行,运行代码输出:1 正确答案:A 2.

在Java语言中,下列说法正确的是:()。 A.

Java访问修饰符按照访问范围由低到高的排列顺序是public,default,protected,private B.

private可以用于外部类的声明 C.

一个Java源文件中声明为public的外部类只能有一个

D.

protected声明的方法不可以被子类重写

正确答案C 3.

请看下列代码()

public class Member{ private Long userId; private String nickName; //以下是getter和sett方法 ?? }

Main方法中的代码:

Member m1=new Member(); m1.setUserId(new Long(100001)); m1.setNickName(“mick”); Member m2=new Member(); m2.setUserId(new Long(100001)); m2.setNickName(“mick”); System.out.println(m1==m2);

System.out.println(m1.equals(m2)); 控制台的输出结果是: A. true false B. false true C. false false D. true ture

正确答案C 4.

下面关于final说法错误的是:() A.

final修饰类时,该类不能被继承。 B.

final修饰方法时,该方法不能被重写。

C.

当引用到使用static final 修饰的常量时,将采用编译期绑定的方式。 D.

当使用final和abstract共同修饰一个类时,final应至于abstract之前。

正确答案D 5.

下列代码的输出结果是()

public static void main(String[] args) { String test = \

String[] tokens = test.split(\ for (String s : tokens)

System.out.print(s + \ } A. a b c B. 1 2 3 C. a1b2c3 D. a1 b2 c3

正确答案A 6.

关于下列代码说法正确的是: public class Money {

private String country, name; public String getCountry() { return country; } }

class Yen extends Money { public String getCountry() { return super.country; } }

class Euro extends Money {

public String getCountry(String timeZone) { return super.getCountry(); } }

A.

Yen类编译正确 B.

Euro类编译正确 C.

Money类编译错误 D.

Yen和Money编译错误

正确答案B 7.

在Java中,Integer.MAX_VALUE表示: B A.

double型最大值 B.

int最大值 C.

long型最大值 D.

char型最大值

正确答案B 8.

运行下列程序:

String str = \ String str1 = \ int index = 0;

while ((index = str.indexOf(str1, index)) != -1) { System.out.print(index+””); index += str1.length(); }

控制台输出的结果是:(b)。 A. 1 8 17 B. 2 9 18 C. 5 12 21 D. 6 13 22 正确答案B 9.

请看下列代码:

public interface A {

String DEFAULT_GREETING = \ public void method1(); }

现有接口B,是A接口的子接口,下列选择中B接口的声明正确的是:A A.

public interface B extends A { } B.

public interface B implements A {} C.

public interface B instanceOf A {} D.

public interface B inheritsFrom A { }

正确答案A 10.

请看下列代码:

public static void main(String[] args) { <插入代码>

System.out.println(s); }

如果程序输出的结果是4247,那么在<插入代码>处应该填入代码是(B)。 A.

String s = \

s = (s-\ B. 89

StringBuffer s = new StringBuffer(\ s.delete(0,3).replace( 1,3, \ C.

StringBuffer s = new StringBuffer(\s.substring(3,6).delete( 1 ,3).insert( 1, \ D.

StringBuilder s = new StringBuilder(\s.substring(3,6).delete( 1 ,2).insert( 1, \

正确答案B 11.

请看下列代码编译和运行的结果是(D)。 interface DeclareStuff {

public static final int EASY = 3; void doStuff(int t); }

public class TestDeclare implements DeclareStuff { public static void main(String[] args) {


达内第一次JAVA考试题.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2017—2018学年度第一学期高二理科数学试卷含答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: