牛客网刷题选择题5

1,

public class IfTest{

    public static void main(string[]args){

        int x=3;

        int y=1;

        if(x=y)

            System.out.println(“Not equal”);

        else

            System.out.println(“Equal”);

     }

}

What is the result?

A The output is “Equal”

B The output in “Not Equal”

C An error at line 5 causes compilation to fall.

D The program executes but does not print a message.

答案是:C

2, 下列不正确的 Java 语言标识符是( )

A Sky

B $Computer

C for

D NULL

解析:C

3,假设如下代码中,若t1线程在t2线程启动之前已经完成启动。代码的输出是()

public static void main(String[]args)throws Exception {
    final Object obj = new Object();
    Thread t1 = new Thread() {
        public void run() {
            synchronized (obj) {
                try {
                    obj.wait();
                    System.out.println("Thread 1 wake up.");
                } catch (InterruptedException e) {
                }
            }
        }
    };
    t1.start();
    Thread.sleep(1000);//We assume thread 1 must start up within 1 sec.
    Thread t2 = new Thread() {
        public void run() {
            synchronized (obj) {
                obj.notifyAll();
                System.out.println("Thread 2 sent notify.");
            }
        }
    };
    t2.start();

 A  Thread 1 wake up Thread 2 sent notify.

Thread 2 sent notify. Thread 1 wake up

C A、B皆有可能

D 程序无输出卡死

解析:B 

4,@SuppressWarnings(“deprecation”)的功能是什么?

A 屏蔽不赞同使用的类和方法的警告

B 屏蔽在强制类型转换的时候编译器给出的警告

C 关闭所有警告信息

D 当在可序列化的类上缺少serialVersionUID定义的警告

解析:A  

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值