/**
* 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.子类不能继承父类的私有属性