名人名言
“Love yourself first and everything else falls into line. You really have to love yourself to get anything done in this world.”
——Lucille Ball
首先爱你自己,其他一切都会井然有序。在这个世界上你必须要爱你自己才能完成任何事情。
——露西尔·鲍尔
“Let us always meet each other with smile, for the smile is the beginning of love.”
——Mother Theresa
2019.04.17问题及解析
请问下列哪项关于HashMap和HashTable的描述是错误的?
A.HashMap允许将null作为一个entry的key或者value,而Hashtable不允许。
B.他们都实现了Map接口。
C.HashMap允许将null作为一个entry的key或者value,而Hashtable不允许。
D.HashMap非线程安全,在多个线程访问Hashtable时,不需要自己为它的方法实现同步,而HashMap就必须为之提供额外同步。
HashMap和HashTable都实现了Map接口。
HashMap允许空值和空键,Hashtable不允许。
HashMap非线程安全,HashTable是线程安全的。
A.HashMap允许空值空键的,Hashtable不允许,正确。
B.他们都实现了Map接口,正确
C.昨天写错了和A选项一样了呢,这里还是把C选项补上,让大家多学习一点知识
C.通过contains方法可以判断一个对象是否存在于Hashtable或者HashMap中。
只有HashTable有contains方法,HashMap没有因此C选项错误
D.HashMap线程不安全,Hashtable线程安全,因此多线程访问时,Hashtable不需要手动同步,而HashMap需要。
因此昨天没有答案呢。还是很多小伙伴都答对了。
2019.04.17问题
public class Father {
Father(){
System.out.println("class Father");
}
{
System.out.println("I'm Father class");
}
static {
System.out.println("class Father static");
}
public static void main(String[] args) {
new Son();
}
}
class Son extends Father{
Son(){
System.out.println("class Son");
}
{
System.out.println("I'm Son class");
}
static {
System.out.println("class Son static");
}
}
请问结果是什么?
A.
class Father static
class Son static
I'm Father class
class Father
I'm Son class
class Son
B.
class Father static
class Son static
class Father
I'm Father class
class Son
I'm Son class
C.
class Father
class Father static
I'm Father class
I'm Son class
class Son static
class Son
D.
class Father static
I'm Father class
class Father
class Son static
I'm Son class
class Son