1、 System.out.println(6+”6″);和System.out.println(“6″+6);输出结果是否一样? 一样
2、 int i = 5;
Integer iInteger = new Integer(i);
Integer jInteger = new Integer(i);
System.out.println(i == iInteger);
System.out.println(iInteger == jInteger);输出结果是什么?
True和false
3、 int i = 4;
for(int j = 0; j < i++; j++) {
System.out.print(”a”);
}此程序能输出多少个”a”?无数个
4、 int k = 3;
do {
System.out.print(”b”);
} while(k++ < 4);此程序输出多少个”b”?2个
5、 for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++) {
if(j == 1) continue;
System.out.print(”c”);
}
}此程序输出多少个”c”?6个
6、 int[] iArray = new int[3];
Integer[] integerArray = new Integer[3];
for(int i = 0; i < iArray.length; i++) {
System.out.println(iArray[i]);
}
for(int i = 0; i < integerArray.length; i++) {
System.out.println(integerArray[i]);
}此程序的输出结果是什么? 0
0
0
null
null
null
7、 private void prValue(int i) {
System.out.println(i + 1);
}
private void prValue(double i) {
System.out.println(i * 2);
}以下程序执行后的结果是什么?
int i = 3;
prValue((double)i);
6.0
8、 public static void chgValue(Integer i) {
i = new Integer(i.intValue() * 2);
}
public static void main(String args[]) {
Integer ins = new Integer(“555”);
chgValue(ins);
System.out.println(ins.toString());
}执行结果是什么?
555
9、 String str1 = ”ab”;
String str2 = ”a” + ”b”;
System.out.println((str1 == str2) + “,” + str1.equals(str2));
输出结果是什么?
true,true
String str3 = “ab”;
String str4 = ”a”;
str4 += “b”;
System.out.println((str3 == str4) + “,” + str3.equals(str4));
输出结果又是什么?
false,true
10、class Super {
public float getNum() {
return 3.0f;
}
}
public class Sub extends Super {
line 6;
}
不可以在line 6 处放入的方法是:B
A、public float getNum() { return 5.0f; }
B、public void getNum() {}
C、public void getNum(double d) {}
D、public double getNum(float f) { return 6.0d; }
11、public class TestMain {
public static String output = ””;
public static void foo(int i) {
try {
if(i == 1) {
throw new Exception();
}
output += “1”;
} catch (Exception ex) {
output += “2”;
return ;
} finally {
output += “3”;
}
output += “4”;
}
public static void main(String args[]) {
foo(0);
foo(1);
System.out.println(output);
}
}以上程序的输出结果是什么?
13423
12、System.out.println(System.in.read());当输入字符a的时候输出结果是什么?
97
13、class Super {
static {
System.out.print(“A”);
}
public Super() {
System.out.print(“B”);
}
}
public class Sub extends Super {
static {
System.out.print(“C”);
}
public Sub() {
System.out.print(“D”);
}
public static void main(String args[]) {
new Sub();
}
}程序输出结果是什么?
ACBD
14、public class Test {
public static int getInt() {
return 3;
}
public static void main(String args[]) {
if(getInt()) {
System.out.println(“A”);
} else {
System.out.println(“B”);
}
}
}程序输出结果是:C
A、A B、B C、编译错误 D、运行错误
15、public class Test {
public static void test(String str) {
if(str == null | str.length() == 0) {
System.out.println(“String is empty”);
} else {
System.out.println(“String is not empty”);
}
}
public static void main(String args[]) {
String aa = null;
test(aa);
}
}程序运行结果是:D
A、String is empty B、String is not empty C、编译错误 D、运行错误
16、苹果是水果,也是一种食物,并且可以吃。现有类Apple, Fruit, Food, IEdible,把它们的关系声明成如下,是否正确,为什么?
Apple extends Fruit,Food implements IEdible
17、String、StringBuffer、StringBuilder三者之间的区别。
18、HashMap和Hashtable的区别
评论列表
文章目录