以下静态方法定义中错误的是()
A: public static void sayHello(){ System.out.println("hello"); }
B: public staticvoid sayHello(){ System.out.println("hello"); return; }
C: public static show(String name){
System.out.println(name); }
D: public staticboolean shiPengyou(){ return true; }
A: public static void sayHello(){ System.out.println("hello"); }
B: public staticvoid sayHello(){ System.out.println("hello"); return; }
C: public static show(String name){
System.out.println(name); }
D: public staticboolean shiPengyou(){ return true; }
举一反三
- 以下静态方法的定义中正确的是() A: static void show(String name){ System.out.println(name);<br> } B: public static int add(int a,int b){ System.out.println(a+b); } C: public static boolean isPass(int x){ if (x>80){<br> return true;<br> }<br> return false;<br> } D: public static void print(int n){ return n;<br> }
- 中国大学MOOC: 下列代码中构造方法的返回类型是()public class Village { Village () { System .out .println(“hiding in Village”) ; } public static void main( String args [ ]) { Village c =new Village ( ) ;}class Village { public static void main( String args [ ]) { Village c =new Village ( ) ; } Village () { System .out .println(“hiding in Village”) ; } }
- class Person{ static{ System.out.println(name); } private static String name = "hello"; } class Demo{ public static void main(String[] args){ Person p = null; } }
- 下列ABCD注释标注的哪行代码有错public class Demo { public static void main(String args[]) { System.out.println("Java"); system.out.println("hello"); System.out.println("你好"); } } A: public class Demo B: public static void main(String args[]) C: system.out.println("ok"); D: System.out.println("您好");
- 下列程序运行结果是 public class Demo { public static void main(String[] args) { Object obj=new Father(){ public void show(){ System.out.println("helloworld"); } }; obj.show(); } } class Father{ public void show(){ System.out.println("hello father"); } }