请阅读下面的程序Public class Test {public static void main(String[] args) {int a = 0;int b = 0;for (int i = 1; i = 0) {b++;}}System.out.println("a=" + a + ",b="+ b);}}下列选项中,哪一个是正确的运行结果()
答:a=-2,b=8
继续答题:下一题
更多JAVA程序设计试题
- 1请阅读下面的程序代码Class Person{void say(){System.out.println("hello");}}class Example{public static void main(String[] args){Person p2 = new Person();Person p1 = new Person(); p2.say();p1.say();p2=null;p2.say();}}下列关于程序运行结果的描述中,正确的是()
- 2下列不属于FileInputStream输入流的read()成员函数的是?
- 3下列关于类和对象的描述,错误的是( )
- 4下列数据类型进行运算时,哪一个会发生自动类型提升
- 5下列程序运行结果是( )interface InterfaceA{String s="good ";void f();}abstract class ClassA{abstract void g();}class ClassB extends ClassA implements InterfaceA{void g(){System.out.print(s);}public void f(){System.out.print(" "+s);}}public class E {public static void main(String[] args) {ClassA a=new ClassB();InterfaceA b=new ClassB();a.g();b.f();}}
- 6线程控制方法中,yield()的作用是()