每日10道JAVA题(20180619)

89 篇文章 2 订阅

/ **   
 * 10道题系列会持续更新,每日的10道题都是我做过的,做错或者觉得需要复习的有价值的
 *请关注我,每日和我一同进步,有更好的建议或有问题的请在评论区提出或私信我
 * /

1.执行以下程序后的输出结果是()


public class Test {
public static void main(String[] args) {
    StringBuffer a = new StringBuffer("A"); 
    StringBuffer b = new StringBuffer("B"); 
    operator(a, b); 
    System.out.println(a + "," + b); 

public static void operator(StringBuffer x, StringBuffer y) { 
    x.append(y); y = x; 
}
}

A.A,A
B.A,B
C.B,B
D.AB,B

2.以下代码在编译和运行过程中会出现什么情况
public class TestDemo{
    private int count;
    public static void main(String[] args) {
        TestDemo test=new TestDemo(88);
        System.out.println(test.count);
    }
     TestDemo(int a) {
         count=a;
    }
}

A.编译运行通过,输出结果是88
B.编译时错误,count变量定义的是私有变量
C.编译时错误,System.out.println方法被调用时test没有被初始化
D.编译和执行时没有输出结果

3.在java中,下列标识符不合法的有( )

A.new
B.$Usdollars
C.1234
D.car.taxi

4.java中,StringBuilder和StringBuffer的区别,下面说法错误的是?

A.StringBuffer是线程安全的
B.StringBuilder是非线程安全的
C.StringBuffer对 String 类型进行改变的时候其实都等同于生成了一个新的 String 对象,然后将指针指向新的 String 对象。
D.效率比较String<StringBuffer<StringBuilder,但是在 String S1 = “This is only a” + “ simple” + “ test”时,String效率最高。

5.Given the following code:
       import EnclosingOne.InsideOne
1.class Enclosingone
2.{
3.    public class InsideOne {}
4.
5.}
6.public class inertest
7.{
8.    public static void main(string[]args)
9.    {
10.        EnclosingOne eo = new EnclosingOne();
11.        //insert code here
12.    }
13.
14.}
Which statement at line 11 constructs an instance of the inner class?

A.InsideOne ei=eo.new InsideOne();
B.eo.InsideOne ei=eo.new InsideOne();
C.InsideOne ei=EnclosingOne.new InsideOne();
D.EnclosingOne.InsideOne ei=eo.new InsideOne();


6.下列程序的输出结果是什么?
public class Test1{
    public static void main(String args[]){
            String a="1234";
            String b="1234";
            String c = new String("1234");
            System.out.println(a==b);
            System.out.println(a==c);
            System.out.println(a.equals(c));
    }
}

A. true
false
true
B true
true
false
C true
false
false
D true
true
true

7.下列代码执行结果为()
public static void main(String args[])throws InterruptedException{
            Thread t=new Thread(new Runnable() {
                public void run() {
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.print("2");
                }
            });
            t.start();
             
            t.join();
            System.out.print("1");
        }


A.21
B.12
C.可能为12,也可能为21
D.以上答案都不对


8.java语言的下面几种数组复制方法中,哪个效率最高?


A.for 循环逐一复制
B.System.arraycopy
C.Array.copyOf
D.使用clone方法

9.以下哪项不属于java类加载过程?

A.生成java.lang.Class对象
B.int类型对象成员变量赋予默认值
C.执行static块代码
D.类方法解析

10.JAVA中,下列语句哪一个正确()

A.class中的constructor不可省略
B.constructor必须与class同名,但方法不能与class同名
C.constructor在一个对象被new时执行

D.一个class只能定义一个constructor

答案

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

StrideBin

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值