文档详情

JAVA编程基础-2-B-试卷.doc

发布:2017-12-17约4.58千字共6页下载文档
文本预览下载声明
软件工程师实训营阶段试卷 课程名称: JAVA编程基础-2-B 考试时间 60分钟(闭卷■) 选择题(每题3分 共60分) 阅读下面代码: public class JavaKey { private int java = 100; //1 public String true = my Java; //2 public static void main(String[] args) { int integer = 20; //3 JavaKey key = new JavaKey(); System.out.println(key.java); } } 下面那个表达式是合法的? 编译成功;打印输出100 编译失败;提示//1处发生错误 编译失败;提示//2处发生错误 编译失败;提示//3处发生错误 下面哪个选项的内容不是java保留字? int throws long TRUE 下面哪个选项的内容不是java中的基本类型? 1 1 1.0 1 阅读下面代码(两个类在同一个package内): class TestClass { static int age; String name; } public class TestVariableInit{ public static void main(String[] args) { TestClass tc = new TestClass(); int j = 0; System.out.println(tc.name= + TestClass.name); System.out.println(tc.age= + tc.age); System.out.println(j= + j); } } 下面关于上述代码的说法哪一个是正确的? 编译通过;输出结果为 tc.name=null tc.age=0 j=0 编译通过;输出结果为 tc.name= tc.age=0 j=0 编译通过;输出结果为 tc.name= tc.age= j= 编译失败 下边哪一个选项中的方法不是在Object类中被声明的? toString() final() getClass() clone() 阅读下面代码 public class Question { public static void main(String[] args) { String s1 = abcd; String s2 = ab + cd; System.out.println(s1+((s1==s2)?==:!=)+s2); } } 上述代码的执行结果是: s1==s2 s1!=s2 s1 s1=abdc 阅读下面代码: public class Foo { public static void main (String [] args) { StringBuffer buf = new StringBuffer(a); add(buf); System.out.println(buf); } static void add(StringBuffer buf) { buf.append(b); } } 上述代码的执行结果是: 编译失败 编译通过,执行结果为a 编译通过,执行结果为ab 编译通过,执行结果为buf变量的地址 阅读下面代码: public class AClass { public static void main(String[] args) { String[] msg = {one,two,three}; if(args.length==0) { System.out.println(No arguments); } else { System.out.println(msg[args.length]+ arguments); } } } 下面哪个选项的说法是正确的? 该代码无法编译通过 不带任何参数运行该程序时,会抛出NullPointerException异常 带3个参数运行该程序时,会打印three arguments 带3个参数运行该程序时,会发生运行时异常 阅读下面代码 public class ThisUse { int plane; static int car; public void doSomething() { float i; //插入语句 } } 下面哪个选项中的内容不能添加到//插入语句处(添加后导致
显示全部
相似文档