Q2. What's the difference between an interface and an abstract class? Q30. What access level do you need to specify in the class declaration to ensure that only classes from the same directory can access it?
java中String类的笔试面试题含答案
1.下面程序的运行结果是()(选择一项)
String str1=”hello”;
String str2=new String(“hello”);
System.out.println(str1==str2);
A. true
B. false
C. hello
D. he
答案:B
分析:str1没有使用new关键字,在堆中没有开辟空间,其值”hello”在常量池中,str2使用new关键字创建了一个对象,在堆中开辟了空间,”==”比较的是对象的