选择题day-1

1.以下代码运行输出的是

public class Persion {
    private String name = "Person";
    int age = 0;
}
public class Child extends Persion {
    public String grade;

    public static void main(String[] args) {
        Persion p = new Child();
        System.out.println(p.name);
    }
}

A 输出:Person B 没有输出 C 编译出错 D 运行出错


2.输出的是

package package1130;
class Base{
    public Base(String s) {
        System.out.print("B");
    }
}
public class Derived extends Base{
    public Derived(String s){
        System.out.print("D");
    }

    public static void main(String[] args) {
        new Derived("D");
    }
}

A、BD B、DB C、C D、编译错误


3.在异常处理中,以下描述不正确的有

A try块不可以省略 B 可以使用多重catch块 C finally块可以省略 D catch块和finally块可以同时省略


4.下列说法正确的是

A 实例方法可直接调用超类的实例方法
B 实例方法可直接调用超类的类方法
C 实例方法可直接调用本类的类方法
D实例方法可直接调用其他类的实例方法


String str1=“hello”;
String str2=“he”+ new String(“llo”);
System.out.println(str1==str2);
请问输出的结果是


程序读入用户输入的一个值,要求创建一个自定义的异常,如果输入值大于 10 ,使用 throw 语句显式地引 发异常,异常输出信息为 ”something’swrong!” ,语句为()
A if(i>10)throw new Exception(“something’swrong!”);
B if(i>10)throw Exception e(“something’swrong!”);
C if(i>10) throw new Exception e(“something’swrong!”);
D if(i>10)throw Exception( “something’swrong!”);


7.以下关于集合类 ArrayList 、 LinkedList 、 HashMap 描述错误的是:

A HashMap实现Map接口,它允许任何类型的键和值对象,并允许将null用作键或值
B ArrayList和LinkedList均实现了List接口
C 添加和删除元素时,ArrayList的表现更佳
D. ArrayList的访问速度比LinkedList快


C:就算是向上转型,child拥有继承父类的属性,但是也有访问权限.
D.编译出错呀,原因是你把参数传入了Derived但是没有传入Base呀,这样就不能先调用了base的构造函数了,所以Derived里面要super(s),传到父类
3.D
4.C
5.false
6.A


7.C

{null=haha, hehe=null}

ArrayList是基于数组实现的查找的时候比较快,删除添加的时候牵扯到搬运,效率低
LinkedList基于链表实现,查找比较慢,但是插入删除会快一丢,直接next.next


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值