第1次作业 一、单项选择题(本大题共80分,共 20 小题,每小题 4 分) 1. 关于下列程序结果正确的是( ) public class MyClass { static int i; public static void main(String argv[]) { (i); } } A. Error Variable i may not have been initialized B. Null C. 1 D. 0 2. 给定程序如下 public static void main(String args[]) { Float f=new Float(); Float c; Double d=new Double(); float fl=; c=f; } 下列选项中( )的值为真. A. (d) B. c=f C. c==d D. (f) 3. 以下由do-while语句构成的循环执行的次数是( ) int k = 0; do { ++k; }while ( k < 1 ); A. 一次也不执行 B. 执行1次 C. 无限次 D. 有语法错,不能执行 4. 如果有类Person和其子类Man和Woman,则如果程序中出现语句Woman w=new Man();下列说法正确的是( ) A. 语句错误 B. 语句正确 C. 编译正确但运行错误 D. 以上均不对 5. 给定以下程序段 //insert code public class foo ( public static void main (String[] args) throws Exception { printWriter out = new PrintWriter (new (), true) ; (“Hello”); ) ) 要使程序能正确运行,在//insert code处必须添加( )语句 A. import ; B. include ; C. import ; D. include ; 6. 下列哪个表达式的值为真( ) A. "john" == "john" B. "john".equals("john") C. "john" = "john" D. "john".equals(new Button("john")) 7. 如果通过命令行java myprog good morning 运行下列程序,结果正确的是( ) A. myprog B. good C. morning D. Exception in thread "main" : 2 at (myprog