每日10道JAVA题(20180728)

89 篇文章 2 订阅

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

 

1.下面有关java hashmap的说法错误的是?

A.HashMap 的实例有两个参数影响其性能:“初始容量” 和 “加载因子”。
B.HashMap 的实现不是同步的,意味着它不是线程安全的
C.HashMap通过开放地址法解决哈希冲突
D.HashMap中的key-value都是存储在Entry数组中的

2.public class Test
{
    public int x;
    public static void main(String []args)
    {
        System. out. println("Value is" + x);
    }
}


A.程序会打出 "Value is 0"
B.程序会抛出 NullPointerException
C.非静态变量不能够被静态方法引用
D.编译器会抛出 "possible reference before assignment"的错误

3.通过JDBC访问数据库包含下面哪几步?

A.载入JDBC驱动程序
B.建立连接
C.执行查询或更新
D.关闭连接

4.public class NameList
{
    private List names = new ArrayList();
    public synchronized void add(String name)
    {
        names.add(name);
    }
    public synchronized void printAll()     {
        for (int i = 0; i < names.size(); i++)
        {
            System.out.print(names.get(i) + ””);
        }
    }
 
    public static void main(String[]args)
    {
        final NameList sl = new NameList();
        for (int i = 0; i < 2; i++)
        {
            new Thread()
            {
                public void run()
                {
                    sl.add(“A”);
                    sl.add(“B”);
                    sl.add(“C”);
                    sl.printAll();
                }
            } .start();
        }
    }
}
Which two statements are true if this class is compiled and run?

A.An exception may be thrown at runtime.
B.The code may run with no output, without exiting.
C.The code may run with no output, exiting normally(正常地).
D.The code may rum with output “A B A B C C “, then exit.
E.The code may rum with output “A B C A B C A B C “, then exit.
F.The code may ruin with output “A A A B C A B C C “, then exit.
G.The code may ruin with output “A B C A A B C A B C “, then exit.

5.代码 的运行结果是()
package com.sunline.java;
public class A implements B extends C{
    public static void main(String args[]){
        System.out.println("hello sunline!");
    }
}

A.在控制台打印hello sunline!
B.报异常java.lang.NullPoninterException
C.编译报错
D.报异常java.lang.RuntimeExcception

6.类Teacher和Student都是类Person的子类。
  Person P;
  Teacher t;
  Student s;
  P,t和s都是非空值
  if(t instanceof Person){s=(Student)t;}
  这个语句导致的结果是______。
A.将构造一个Student对象  
B.表达式合法,编译时报错 
C.表达式错误的
D.编译时合法而在运行时可能非法
  
7.public class P {
    public int pv(int a,int b) {
        int s;
        s=a+b;
        return s;
    }
}
public class S extends P{
}

A.int pv(int a,int b) {return a+b;}
B.public void pv(int a,int b) {}
C.public int pv(int a) {return a;};
D.public int pv(int a,int b) throws Exception{return a+b;}


8.public class Cups {
     long length;
     public Cups(long l) {
         length=l;
     }
   public static void main(String[] args) {
      Cups s1,s2,s3;
      s1=new Cups(21L);
      s2=new Cups(21L);
      s3=s2;
      long m=21L;
   }  
}  
下列返回为true的是哪个

A.s1==s2;
B.s2==s3;
C.m==s1;
D.s1.equals(m);

9.下列关于final的数据说法正确的是()

A.final定义的数据,不能同时为private
B.final定义的数据,如果同时为static,就不能用private
C.final定义的数据,必须被初始化,而且只能在定义时初始化
D.final定义的数据,必须被初始化,可以在定义时初始化,也可以在构造函数中初始化

10.以下有关类的继承的叙述中,正确的是()

A.子类能直接继承父类所有的非私有属性,也可以通过接口继承父类的私0有属性
B.子类只能继承父类的方法,不能继承父类的属性
C.子类只能继承父类的非私有属性,不能继承父类的方法
D.子类不能继承父类的私有属性

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

StrideBin

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

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

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

打赏作者

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

抵扣说明:

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

余额充值