A: public String foo() { return “我爱中国”; }
B: public void foo(){
return ”-我爱中国”; }
C: public String foo(){
String s=”我爱中国”; return s; }
D: public int foo(){
String s=“我爱中国”; return s; }
举一反三
- 读代码:public class foo {static String s;public static void main (String[]args) {System.out.println (“s=” + s);}}结果是
- Which two methods, inserted individually, correctly complete the Three class?() A: public void foo(){ } B: public int foo(){return 3;} C: public Two foo(){return this;} D: public One foo(){return this;} E: public Object foo(){return this;}
- 下面代码的运行结果为:( ) import java.io.*; import java.util.*; public class foo{ public static void main (String[] args){ String s; System.out.println("s=" + s); } }
- Which code, inserted at line 15, allows the class Sprite to compile?() A: Foo{public int bar(){return 1;}} B: new Foo{public int bar(){return 1;}} C: new Foo(){public int bar(){return 1;}} D: new class Foo{public int bar(){return 1;}}
- 阅读以下代码: public class foo{ public static void main (String[] args){ String s; System.out.println("s=" + s); 输出结果应该是
内容
- 0
读代码: public class Test { public static void main (String args[]) { class Foo { public int i = 3; } Object o = (Object) new Foo(); Foo foo = (Foo)o; System.out.println(foo.i); } } 结果是:
- 1
关于下列代码说法正确的是( ) public class Foo{ public int add(int a,int b){ return a+b; } public static void main(String[] args){ Foo foo = null; System.out.println(foo.add(10,20)); } }
- 2
智慧职教: public class Foo{ int i; static String s; void imethod(){ } static void smethod(){ }}已知f是Foo的一个实例,下面语句是否正确?Foo.imethod()
- 3
阅读程序,下面的哪个选项是正确的?( )。 class ExSuper{ String name; String nick_name; public ExSuper(String s,String t) { name = s; nick_name = t; } public String toString(){ return name; } } public class Example extends ExSuper{ public Example(String s,String t){ super(s,t); } public String toString(){ return name +"a.k.a"+nick_name; } public static void main(String args[]){ ExSuper a = new ExSuper(“First”,“1st”); ExSuper b = new Example(“Second”,“2nd”); System.out.println(“a is”+a.toString()); System.out.println("b is"+b.toString()); } }
- 4
智慧职教: 192.阅读以下代码: import java.io.*; import java.util.*; public class foo{ public static void main (String[] args){ String s; System.out.println("s=" + s); } } 输出结果应该是( )