一: 选择题 1
关于以下程序代码的说明正确的是( D ) 1.class HasStatic{ 2. private static int x=100; 3. public static void main(String args[ ]){ 4. HasStatic hs1=new HasStatic( ); 5. hs1
x++; 6. HasStatic hs2=new HasStatic( ); 7. hs2
x++; 8. hs1=new HasStatic( ); 9. hs1
x++; 10. HasStatic
x- -; 11. System
println(“x=”+x); 12. } 13. } A、 5 行不能通过编译,因为引用了私有静态变量 B、 10 行不能通过编译,因为 x 是私有静态变量 C、 程序通过编译,输出结果为:x=103 D、 程序通过编译,输出结果为:x=102 2
下列关于for循环和w hile循环的说法中哪个是正确的
( B ) A.while 循环能实现的操作,for 循环也都能实现 B.while 循环判断条件一般是程序结果,for 循环判断条件一般是非程序结果 C.两种循环任何时候都可替换 D.两种循环结构中都必须有循环体,循环体不能为空 3
以下选项中循环结构合法的是( C ) A、while (int i