栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > Java面试题

Java试题

Java面试题 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Java试题

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 nullnullnull7、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.08、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());}执行结果是什么?5559、String str1 = ”ab”;String str2 = ”a” + ”b”;System.out.println((str1 == str2) + “,” + str1.equals(str2));输出结果是什么?true,trueString str3 = “ab”;String str4 = ”a”;str4 += “b”;System.out.println((str3 == str4) + “,” + str3.equals(str4));输出结果又是什么?false,true10、class Super {public float getNum() {return 3.0f;}}public class Sub extends Super {line 6;}不可以在line 6 处放入的方法是:BA、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);}}以上程序的输出结果是什么?1342312、System.out.println(System.in.read());当输入字符a的时候输出结果是什么?9713、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();}}程序输出结果是什么?ACBD14、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”);}}}程序输出结果是:CA、AB、BC、编译错误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);}}程序运行结果是:DA、String is empty B、String is not empty C、编译错误D、运行错误16、苹果是水果,也是一种食物,并且可以吃。现有类Apple, Fruit, Food, IEdible,把它们的关系声明成如下,是否正确,为什么?Apple extends Fruit,Food implements IEdible17、String、StringBuffer、StringBuilder三者之间的区别。18、HashMap和Hashtable的区别

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/264595.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号