王朝网络
分享
 
 
 

SUN JAVA 110_新版答案更正了部分错误

王朝java/jsp·作者佚名  2006-01-31
宽屏版  字体: |||超大  

1、从下面列表中选取3个合法的标识符

A. IDoLikeTheLongNameClass

B. $byte

C. const

D. _ok

E. 3_case

(a b d)

2、如何对一个对象进行强制垃圾回收 How can you force garbage collection of an object?

A. 不能强制进行垃圾回收 Garbage collection cannot be forced

B. 调用 System.gc().

C. 传递要进行垃圾回收的对象的引用作为参数,调用 System.gc()

D. 调用 Runtime.gc()[x1] .

E. 设置所有对该对象的引用到一个新值(如null).

(b,e)

3、考虑下面的类

public class test {

void test(int i) {

System.out.println("I am an int.");

}

void test(String s) {

System.out.println("I am a string.");

}

public static void main(String[] args) {

test t=new test();

char ch='y';

t.test(ch);

}

}

4、下面哪一句说法是正确的(选择一个)

A. 第5行不能通过编译,因为void方法不能被重写。

B. 第12行不能通过编译,因为没有任何一个test方法接收一个字符参数。

C. 代码可以通过编译但会在第12行抛出一个异常。

D. 代码可以通过编译且运行时可输出:’ I am an int.’ 。

E. 代码可以通过编译且运行时可输出:’ I am a String.’ 。

(d)

5、数组numArray 的第9个元素可以表示为The ninth element of numArray is identified as follows,________ .

A. numArray[8];

B. numArray[9];

C. numArray[] = 9;

D. numArray[7] += 2;

(a)

6、 下面的哪个语句声明了一个有10个元素的数组?

A int numbers[] = new int[10];

B int numbers[10];

C int numbers[] = 10;

D new int numbers[] = int[10];

(a)

7、. AWT表示 __________ .

A Automated Windowing Toolkit

B Automatic Workspace Toolkit

C Abstract Windowing Toolkit

D Absolutely Wacky Things

(c)

8、 下面的代码段说明了面向对象的哪一特性__________ .

public void overload(String s){...}

public void overload(int i){...}

public void overload(int i, float f){...}

A 多继承

B 多态

C 覆盖

D 重载

(d)

9、 当子类的一个方法和父类的一个方法命名相同时,叫做__________ .

A overloading重载

B instance实例

C overriding覆盖

D local scope局域变量

(c)

10、 Which of the following defines a "Car" class, which it to behave just like a "Vehicle" class except that it has additional methods?

A Vehicle Car{...}

B class Vehicle extends Car{...}

C class Car extends Vehicle{...}

D class Car implements Vehicle{...}

(c)

11、 下面关于抽象类的说法那些是正确的?

A 不能从它继承一个子类

B 该类不能实例化

C 所有的方法必须都是抽象方法

D 抽象类的定义中必须包含abstract关键字

(b d)

12、 关键字 ________表示一个对象或变量一旦赋值就不能修改

A static

B final

C constant

(b)

13、问:Which of the following lines of code will compile without error?

(A).

int i=0;

if(i[x2] ){

System.out.println("Hi");

}

(B).

boolean b=true;

boolean b2=true;

if(b==b2){

System.out.println("So true");

}

(C).

int i=1;

int j=2;

if(i==1||j=[x3] 2)

System.out.println("OK");

(D).

int i=1;

int j=2;

if(I==1&|[x4] j==2)

System.out.println("OK");

(b )

14、如下代码

class Test{

private int m;

public static void fun() {

// some code...

}

}

15、如何才能重载方法 fun()中直接访问变量[x5] m?

A. 改变 private int m 为 protected int m

B. 改变private int m为public int m

C. 改变private int m为static int m

D. 改变private int m为int m

(c)

16、下面方法哪个[x6] 是方法 public void example(){...} 的正确重载?

A. public void example( int m){...}

B. public int example(){...}

C. public void example2(){...}

D. public int example ( int m, float f){...}

(a d)

17、Java中 main()方法的返回值类型为?

A. String

B. int

C. char

D. void

(d)

18、下面那些是Java的合法描述符?

A. fieldname

B. super

C. 3number

D. #number

E. $number

(a e)

19、哪些是java合法的关键字

A. const

B. NULL

C. false

D. this

E. native

(a[x7] c d e)

20、哪些是 Java中正确的整数表达式?

A. 22

B. 0x22

C. 022

D. 22H

(a b c )

21、下面的代码段执行后I和j的值为

int i = 1;

int j;

j = i++;

A. 1, 1

B. 1, 2

C. 2, 1

D. 2, 2

(c)

22、下面哪些说法是正确的Which of the following statements are true?

A. >>是算术右移符

B. >>是逻辑右移符

C. >>> 是算术右移符

D. >>> 是逻辑右移符

(a,d)

23、哪些赋值是正确的

A. float a = 2.0[x8]

B. double b = 2.0

C. int c = 2

D. long d = 2

(b c d)

24、main()方法中的参数的正确描述是

A. char args[]

B. char args[][]

C. String arg[]

D. String args

(c)

25、下面哪些可正确的创建一个数组

A. float f[][] = new float[6][6];

B. float []f[] = new float[6][6];

C. float f[][] = new float[][6];

D. float [][]f = new float[6][6];

E. float [][]f = new float[6][];

(a b d e)

26、对于给定的表达式: int m[] = {0, 1, 2, 3, 4, 5, 6 },下面哪些计算结果等于数组的长度

A. m.length()

B. m.length[x9]

C. m.length()+1

D. m.length+1

(b)

27、用这样的命令行执行正确的类 : java MyTest a b c,下面哪些是正确的?

A. args[0] = "MyTest a b c"

B. args[0] = "MyTest"

C. args[0] = "a"

D. args[1]= 'b'

(c[x10] )

28、给定代码:

public class Test{

long a[] = new long[10];

public static void main ( String arg[] ) {

System.out.println ( a[6] );[x11]

}

哪句是正确的?

A. 无输出

B. 输出是0

C. 出现编译时错误

D. 出现运行时错误

( c)

29、给定下面的代码:

public class test {

public static void main(String[] args) {

int i = 5;

do {

System.out.println(i);

} while (--i>5);

System.out.println("finished");

}

}执行时输出:

A. 5

B. 4

C. 6

D. Finished

E. None

(a d)

30、如下代码:

switch (m){

case 0: System.out.println("Condition 0");

case 1: System.out.println("Condition 1");

case 2: System.out.println("Condition 2");

case 3: System.out.println("Condition 3");break;

default: System.out.println("Other Condition");

}

m的值是多少可以输出来 "Condition 2"?

A. 0

B. 1

C. 2

D. 3

E. 4

F. None

(a b c)

31、Java中哪些是合法的修饰府?

A. private

B. public

C. protected

D. protect

E. friend

(a b c)

32、如果一个类变量只能在同一包内被访问可用那个修饰符?

A. private

B. public

C. protected

D. 不用修饰

E. final

(d)

33、下面哪种对类变量的修饰可以定义常量

A. static

B. final

C. abstract

D. No modifier can be used

( b)

34、下面哪些是对native方法的正确声明?

A. public native void test();

B. public native void test(){}

C. public void native test();

D. public native test(){}

(a[x12] )

35、给定类的定义

public class Test {

private float f = 1.0;

int m = 12;

static int n=1;

public static void main(String arg[]) {

Test t = new Test();

// some code...

}

}

36、在注释处哪种用法是合法的?

A. t.f

B. this.n

C. Test.m

D. Test.n

(a)

37、Given the following code:

A class Example{

B String str;

C public Example(){

D str= "example";

E }

F public Example(String s){

G str=s;

H }

I }

10) class Demo extends Example{

1A }

1B public class Test{

1C public void f () {

1D Example ex = new Example("Good");

1E Demo d = new Demo("Good");

1F }

哪行会引起错误?

A. line 3

B. line 6

C. line 10

D. line 14

E. line 15

(e)

38、给定源文件中的类定义Given the following class definition in one source file:

class Base {

public Base (){ //... }

public Base ( int m ){ //... }

protected void fun( int n ){ //... }

}

public class Child extends Base{

// member methods

}

39、下面哪种可以恰当的加到Child 类中?

A. private void fun( int n ){ //...}

B. void fun ( int n ){ //... }

C. protected void fun ( int n ) { //... }

D. public void fun ( int n ) { //... }

(c d)[x13]

Question: 34

40、下面哪些说法是正确的?

A.在Java中允许单继承,这使得代码更可靠

B.子类可以继承父类的所有方法(包括构造方法)

C. 一个类可以实现任意多的接口

D. 当一个类实现一个接口时,它可以定义接口的一部分方法

(a b c )

41、在源文件 Test.java 中, 哪些类的声明是正确的?

A.

public class test {

public int x = 0;

public test(int x) {

this.x = x;

}

}

B.

public class Test{

public int x=0;

public Test(int x) {

this.x = x;

}

}

C.

public class Test extends T1, T2 {

public int x = 0;

public Test (int x) {

this.x = x;

}

}

D.

public class Test extends T1{

public int x=0;

public Test(int x){

this.x = x;

}

}

E.

protected class Test extends T2{[x14]

public int x=0;

public Test(int x){

this.x=x;

}

}

(b d)

42、如下代码:

public class Test{

public static void main(String args[]){

String str=new String("World");

char ch[]={'H','e','l','l','o'};

change(str,ch);

System.out.println(str + "and" + ch);

}

public static void change(String str, char ch[]){

str="Changed"; ch[0]='C';

}

}

执行的结果是?

A. World and Hello

B. World and Cello

C. Changed and Hello

D. Changed and Cello

(b)

43、下面语句行哪些编译时没有警告或错误

A float f=1.3;

B char c="a";

C byte b=257;

D boolean b=null;

E int i=10;

(e)

44、编译运行下面的代码时会打印

public class MyClass {

public static void main(String arguments[]) {

amethod(arguments);

}

public void amethod(String[] arguments) {

System.out.println(arguments);

System.out.println(arguments[1]);

}

}

A error Can't make static reference to void amethod.

B error method main not correct

C error array must include parameter

D amethod must be declared with String

(a)

45 下面哪些没有编译错误?

A

import java.awt.*;

package Mypackage;

class Myclass {}

B

package MyPackage;

import java.awt.*;

class MyClass{}

C

/*This is a comment */

package MyPackage;

import java.awt.*;

class MyClass{}

(b c)

46、一个字节(byte)的范围是

A -128 to 127 [x15]

B (-2 power 8 )-1 to 2 power 8

C -255 to 256

D依赖于特定的Java虚拟机的实现

(a )

47、运行下面的命令行时会打印

java myprog good morning

public class myprog{

public static void main(String argv[]){

System.out.println(argv[2]);

}

}

A myprog

B good

C morning

D Exception raised: "java.lang.ArrayIndexOutOfBoundsException: 2"

(c)

48、哪些是java的关键字或保留字?

A if

B then

C goto

D while

E case

(a c [x16] e)

49、哪些是合法的描述符?

A 2variable

B variable2

C _whatavariable

D _3_

E $anothervar

F #myvar

(b c d e)

50、编译运行下面的代码时会打印

public class MyClass{

static int i;

public static void main(String argv[]){

System.out.println(i);

}

}

A Error Variable i may not have been initialized

B null

C 1

D 0

(d)

51、编译运行下面的代码时会打印

public class Q {

public static void main(String argv[]){

int anar[]=new int[]{1,2,3};

System.out.println(anar[1]);

}

}

A 1

B Error anar is referenced before it is initialized

C 2

D Error: size of array must be defined

(c )

52、编译运行下面的代码时会打印

public class Q {

public static void main(String argv[]){

int anar[]=new int[5];

System.out.println(anar[0]);

}

}

A Error: anar is referenced before it is initialized

B null

C 0

D 5

(c)

53、编译运行下面的代码时会打印

abstract class MineBase {

abstract void amethod();

static int i;

}

public class Mine [x17] 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 会打印5个0的序列

B Error: ar is used before it is initialized

C Error Mine must be declared abstract

D IndexOutOfBoundes Error

( c)

54、编译运行下面的代码时会打印

int i=1;

switch (i) {

case 0: System.out.println("zero");

break;

case 1:

System.out.println("one");

case 2: System.out.println("two");

default: System.out.println("default");

}

A one

B one, default

C one, two, default

D default

( c)

55、编译运行下面的代码时会打印

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 default子句是错误的

D 没有输出

(b)

56、下面得代码行哪个没有编译错误

A

int i=0;

if(i) { System.out.println("Hello"); }

B

boolean b=true;

boolean b2=true;

if(b==bB {

System.out.println("So true");

}

C

int i=1;

int j=2;

if(i==1|| j==B System.out.println("OK");

D

int i=1;

int j=2;

if(i==1 &| j==B System.out.println("OK");

57、下面那些说法是正确的?

A 方法不能被重写得封装得更隐秘

B 不能重载静态方法

C 不能重载private方法

(b c)

58、当编译运行下面代码时会

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 编译运行都没有错

B编译时出错

C 运行时异常 [x18]

( c)

59、下面的说法那些是正确的?

A System.out.println( -1 >>> B;会输出一个大于10的结果

B System.out.println( -1 >>> B; 会输出一个正数

C System.out.println( 2 >> A; 会输出数字1

D System.out.println( 1 <<< B; 会输出数字4

60、当编译和运行下面代码时会显示:

//Code start

import java.awt.*;

public class Butt extends Frame{

public static void main(String argv[]){

Butt MyBut=new Butt();

}

Butt(){

Button HelloBut=new Button("Hello");

Button ByeBut=new Button("Bye");

add(HelloBut);

add(ByeBut);

setSize(300,300);

setVisible(true);

}

}//Code end

A两个按钮相邻占据整个框架, Hello按钮在左边Bye在右边

B只有Hello按钮占据整个框架

C 只有Bye按钮占据整个框架

D Hello按钮和Bye按钮出现在框架的上面

( c)

61、下面的代码执行时会输出:

public class MyFor{

public static void main(String argv[]){

int i;

int j;

outer:

for (i=1;i <3;i++)

inner:

for(j=1; j<3; j++) {

if (j==2) continue outer;

System.out.println("Value for i=" + i + " Value for j=" +j);

}

}

}

A Value for i=1 Value for j=1

B Value for i=2 Value for j=1

C Value for i=2 Value for j=2

D Value for i=3 Value for j=1

(a b)

62、如下声明:

String s1=new String("Hello");

String s2=new String("there");

String s3=new String();

下面哪个语句是正确的?

A s3=s1 + s2;

B s3=s1-s2;

C s3=s1 & s2;

D s3=s1 && s2

(a)

63、下面语句的计算结果是什么?

System.out.println(4 | 3);

A 6

B 0

C 1

D 7

(d)

64、public class MyClass1{

public static void main(String argv[]){ }

/*Modifier at XX */

class MyInner {}

}

What modifiers would be legal at XX in the above code?

A public

B private

C static

D friend

(a b c )

65、Applet的默认布局管理器是FlowLayout. 怎样用代码把布局管理器换成其他布局管理器?

A setLayoutManager(new BorderLayout ());

B setLayout(new BorderLayout ());

C setGridLayout(2,B;

D setBorderLayout();

(b)

66、当试图编译和运行下面的代码时会出现什么情况?

public class Conv{

public static void main(String argv[]){

Conv c=new Conv();

String s=new String("ello");

c.amethod(s);

}

public void amethod(String s){

char c='H';

c[x19] +=s;

System.out.println(c);

}

}

A 编译成功并输出"Hello"

B 编译成功并输出"ello"

C 编译成功并输出"elloH"

D 编译时错误

(d )

67、下面的代码会输出?

public class Pass{

static int j=20;

public static void main(String argv[]){

int i=10;

Pass p = new Pass();

p.amethod(i);

System.out.println(i);

System.out.println(j);

}

public void amethod(int x){

x=x*2;

j=j*2;[x20]

}

}

A Error: amethod parameter does not match variable

B 20 and 40

C 10 and 40

D 10, and 20

(c)

68、下面的代码会打印出?

public class Oct{

public static void main(String argv[]){

Oct o = new Oct();

o.amethod();

}

public void amethod(){

int oi= 012;

System.out.println(oi[x21] );

}

}

A 12

B 012

C 10

D 10.0

(c)

69当试图编译和运行下面的代码时,会出现什么情况?

public class Ref{

public static void main(String argv[]){

Ref r = new Ref();

r.amethod(r);

}

public void amethod(Ref r){

int i=99;

multi(r);

System.out.println(i);

}

public void multi(Ref r){

r.i = r.i*2;

}

}

A 在编译时出错

B 输出 99

C 输出 198

D 在运行时出错

(b)

70、当试图编译和运行下面的代码时,会出现什么情况?

public class Scope{

private int i;

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

s.amethod();

}//End of main

public static void amethod(){

System.out.println(i);

}//end of amethod

}//End of class

A 打印0

B 什么都不打印

C 编译错误

D 编译错误指出i的作用域不对

[x22] (d )

[x1]应该是Runtime.getRuntime.gc()

[x2]类型不兼容

[x3]应该是==

[x4]有问题

[x5]如果还是同一个变量,肯定就是静态变量

[x6]从题目看似乎是单选题,也许是翻译的问题。

[x7]const也是保留关键字,只是不推荐使用。

[x8]2.0f

[x9]数组求长度注意写法,不要写成m.length();

[x10]args[0]为a

args[1]为b ,args[2]为c

[x11]当数组定义出现在主方法中,结果为0

[x12]注意native方法的写法,后面没有花括号,常用在将c语言写的dll文件引入java中

[x13]A B答案使其限定范围变弱

[x14]类test

修饰非法,只允许使用公用,抽象,终态。

[x15]-127 to 128

[x16]java不推荐使用goto语句

[x17]类必须使用继承的抽象方法amethod()

[x18]

Exception in thread "main" java.lang.ClassCastException: Base

at CEx.main(CEx.java:7)

[x19]c是字符型变量,不能用字符串的加法运算,应该将c改为字符串型变量,这样的话,结果就是Hello

[x20]j是静态变量,所以在这个方法中还依然在其作用域中

[x21]转换成了10进制输出

[x22]不能编译的原因是不能对非静态字段i进行静态引用。选d答案要更接近这个理由一些,实际上c也比较合理。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
>>返回首页<<
推荐阅读
 
 
频道精选
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
© 2005- 王朝网络 版权所有