阅读下列程序,写出程序运行的结果:public class Class431 {public static void main(String[] args) {int a = 3;char m='a';prt("m in main="+m);prt("a in main="+a);prt("return from test2:"+test2());prt("m+a="+test1(m,a));}static float test1(char x, int y) {int z = x+y;return z;}static float test2() {int a = 60;for (int i = 8; i < 12; i++)a= a+i;prt("a in test2 is:"+a);return a;}static void prt(String s) {System.out.println(s);}}
查看答案
阅读下列程序,写出程序运行的结果:class Cube{int width;int height;int depth;Cube(int x,int y,int z){this.width=x;this.height=y;this.depth=z;}public int vol(){return width*height*depth;}}public class UseCube {public static void main(String[] args) {Cube a=new Cube(3,4,5);System.out.println("长度="+a. width);System.out.println("体积="+a.vol());}}
阅读下列程序,写出程序运行的结果:publicclassClass432{staticinti=123;publicstaticvoidmain(String[]args){inti=456;System.out.println("main()中的i="+i);m1();m2();}staticvoidm1(){inti=789;System.out.println("m1()中的i="+i);}staticvoidm2(){System.out.println("类变量i="+i);i+=6;System.out.println("加6后的类变量i="+i);}}
阅读下列程序,写出程序运行的结果:class Demo {public void test (){System.out.println ("NO");}public void test (int i){System.out.println (i);}public void test (int a, int b){System.out.println (a+b);}}public class Test {public static void main(String args[]){Demo de=new Demo();de.test();de.test(5);de.test(6,8);}}
下列程序的输出结果是什么?public class Foo{static int i=0;static int j=0;public static void main(String[] args){int i=2;int k=3;int j=3;System.out.println("i+j is "+i+j);k = i +j;System.out.println("k is "+k);System.out.println("j is "+ j);}}