下列代码的运行结果为public class Method{public String show(String name){String oneSelf=name+"今年7岁了";return oneSelf;}public static void main(String args[]){Method method=new Method();System.out.println(method.show("晓明"));}}
A. 没有任何输出
B. 编辑错误
C. 晓明今年7岁了
D. 晓明
查看答案
下列代码运行的结果是public class Method{public void print(){System.out.print("Hello"+",");}public void my(){System.out.println("My name is Tom.");}public static void main(String args[]){Method method=new Method();method.print();System.out.println("My name is Peter."}}
A. Hello,My name is Tom.
B. Hello,My name is Peter.
C. Hello,My name is Peter.My name is Tom.
D. My name is Peter.
下列语句的执行结果为public class Method{private String mySelf(){String name="Tom";String mySelf="我的英文名叫"+name;return mySelf;}public static void main(String args[]){Method method=new Method();method.mySelf();}}
A. 运行异常
B. 运行错误
C. 我的英文名叫Tom
D. 什么都不输出
下面这段程序的执行结果为public class Method{public void sum(int a,int b,int c){int sum=a+b=以;System.out.println("a+b+c="+sum);}public static void main(String args[]){Method method=new Method();method.sum(12,4,0);}}
A. 12
B. a+b+c=12
C. a+b+c=16
D. 16
已知如下代码,则位置(1)处正确的方法调用代码为public class MethodDemo{public void display(int[] a){System.out.println("打印数组");}public static void main(String args[]){int[] arr={1,2,3,4,5};MethodDeom method=new MethodDemo();//(1)方法调用}}
A. method.display(arr);
B. method.display(arr[0]);
C. method.display(a);
D. method.display(a[0])