java编程应用题答案_JAVA程序设计练习题集答案

一、判断题

String字符串在创建后可以被修改。 ( 0 )

引用一个类的属性或调用其方法,必须以这个类的对象为前缀。 ( 0 final 类名 )

当调用一个正在进行线程的stop()方法时,该线程便会进入休眠状态。 ( 0 )

如果一个类声明实现一个接口,但没有实现接口中的所有方法,那么这个类必须是abstract类。 ( 1 )

构造函数名应与类名相同,返回类型为void。 ( 0 )

把数组中元素按某种顺序排列的过程叫做查找。 ( 0 )

对于abstract类,不能创建该类的对象。 ( 1 )

所有异常都必须捕获。 ( 0 )

可以使用protected修饰符来防止方法和数据被不同包的非子类访问。 ( 1 )

在Java程序中,可以使用private来修饰一个类。 ( 1 )

不允许使用final来修饰abstract方法。 ( 0 )

可以使用protected修饰符来防止方法和数据被不同包的非子类访问。 ( 1 )

An event can be defined as a signal to the program that something has happened. ( )

An event is an object created from an event source. ( )

A program cannot choose to ignore an event. ( )

An event in JavaFX is an object of the javafx.event.Event class.。 ( )

InputStream类和OutputStream类是所有二进制I/O的根类。 ( 1 )

InputStream and OutputStream read and write 8-bit data. ( 1 )

二、单选题

Java程序默认引用的包是( b )。

A.java.awt包

B.java.lang包

C.java.util包

D.java.text包

以下代码的输出结果为( D )。

public class Pass{

static int j = 20;

public void amethod(int x){

x = x*2;

j = j*2;

}

public static void main(String args[]){

int i = 10;

Pass p = new Pass();

p.amethod(i);

System.out.println(i+" and "+j);

}

}

A.10 and 20

B.错误:方法参数与变量不匹配

C.20 and 40

D.10 and 40

若A1、A2为已定义的接口 ,以下接口定义中没有语法错误的是( A ) 。

A.interface B { void print();}

B.interface B { void print() { } }

C.abstract interface B { void print() }

D.abstract interface B extends A1,A2 { abstract void print(){ };}

将以下哪种方法插入行3是不合法的。 ( A )

1.public class Test1{

2. public float aMethod(float a,float b){ }

3.

4.}

A.public float aMethod(float c,float d){ }

B.public int aMethod(int a, int b){ }

C.private float aMethod(int a,int b,int c){ }

D.public float aMethod(float a, float b,float c){ }

你怎样强制对一个对象立即进行垃圾收集? ( E )

A.调用System.gc(), 同时传递要进行垃圾收集对象的引用

B.调用 Runtime.gc()

C.给这个对象的所有引用设置一个新的值(例如null)

D.调用 System.gc()

E.垃圾收集是不能被强迫立即执行

Which statement about the garbage collection mechanism are true? ( )

A.The programmer can indicate that a reference through a local variable is no longer of interest.

B.The programmer has a mechanism that explicity and immediately frees the memory used by Java objects.

C.Garbage collection require additional programe code in cases where multiple threads are running.

D.The garbage collection mechanism can free the memory used by Java Object at explection time.

关于以下程序代码的说明正确的是( B )。

1.class HasStatic{

2. private static int x=100;

3. public static void main(String[ ] args){

4. HasStatic hs1=new HasStatic( );

5. hs1.x++;

6. HasStatic hs2=new HasStatic( );

7. hs2.x++;

8. hs1=new HasStatic( );

9. hs1.x++;

10. HasStatic.x--;

11. System.out.println(“x=”+x);

12. }

13. }

A.程序通过编译,输出结果为:x=103

B.程序通过编译,输出结果为:x=102

C.5行不能通过编译,因为引用了私有静态变量

D.10行不能通过编译,因为x是私有静态变量

Which of the following statements about the Java keywords is true? ( )

A.they can never be used as identifiers

B.they can never be used in comments

C.they are not case-sensitive

D.they can also be used as identifiers

方法体内定义的变量称局部变量,下述关于局部变量的说法中错误的是( A )。

A.局部变量不能与类中的成员变量同名

B.局部变量未经赋值不能使用

C.局部变量仅在所定义的代码块内(花括号对内)有效

D.局部变量不能加修饰词修饰

有一段java 应用程序,它的主类名是a1,那么保存它的源文件名可以是( D ).

A.a1.class

B.a1

C.都对

D.a1.java

A JavaFX action event handler contains a method __. ( )

A.public void actionPerformed(ActionEvent e)

B.public void handle(Event e)

C.public void actionPerformed(Event e)

D.public void handle(ActionEvent e)

A JavaFX event handler for event type T is an instance of _. ( )

A.EventHandler

B.ActionEvent

C.Action

D.EventHandler

To handle the mouse click event on a pane p, register the handler with p using __. ( )

A.p.setOnMouseClicked(handler);

B.p.setOnMouseReleased(handler);

C.p.setOnMouseDragged(handler);

D.p.setOnMousePressed(handler);

Fill in the code below in the underline: ( )

public class Test {

public static void main(String

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值