【单选题】关于下列代码说法正确的是: public class Cell{ public void drop(){ } public String drop(){ return "下落一行"; } public double drop(int x){ return "下落x行"; } }A.无编译错误B.代码public String drop(){行,出现编译错误C.代码public double drop(int x){行,出现编译错误D.代码return "下落一行";行处出现编译错误

【单选题】关于下列代码说法正确的是: public class Cell{ public void drop(){ } public String drop(){ return "下落一行"; } public double drop(int x){ return "下落x行"; } }

A.无编译错误

B.代码public String drop(){行,出现编译错误

C.代码public double drop(int x){行,出现编译错误

D.代码return "下落一行";行处出现编译错误


参考答案和解析
修改表中“姓名”属性

相关考题:

下列程序的功能是为变量赋值,程序运行后,输出i=51。请改动main方法中的错误,使程序能够正确编译、运行并输出正确的结果。注意:不改动程序结构。class A{private int a;public void setA (int x){a=x;}public int getA(){return a;}}public class MethodTest{public static void main(String args[]){A a=A();a.getA(51);int i=a.getA();System.out.println ("i="+i);}}

执行下列代码后,输出的结果为( )。 class Base { int x = 30; void setX( ) {x=1O;} } class SubClass extends Base { int x=40; void setX ( ) {x=20;} int getX( ) {return super. x; } } public class Test { public static void main(String[ ] args) { SubClass sub=new SubClass( ); sub. setX( ); System. out. println(sub, getX( ) ); } }A.10B.20C.30D.40

下列程序段中,正确的是______。 ①class MvClass { int var = 100; static int getVar() { return var; } } ②public class MyClass { final int date; void MyClass (int d) { date = d; } } ③public class MyMain { public static void main(String args[]) { System.out.println(Myclass1.date); } } class MyClass1 { int data = 10; } ④class IamAbstract { final int f; double d; abstrct void method(); }A.②④B.①③C.②D.以上都不对

执行下面程序,显示的结果为( )。 public class Test { public static void main (String args[]) { Test t=newTest(); System.out.println (Loverload ("2","3")); } int overload (intx,int y) {return x+y;} String overload (String x,Stnng y){return x+y;} }A.2B.3C.5D.23

public class Something {public int addOne(final int x) {return ++x;}}这个比较明显。

将下面程序补充完整。 include using namespace std; class Base{ public: 【 】fun(){r 将下面程序补充完整。include <iostream>using namespace std;class Base{public:【 】 fun(){return 0;} //声明虚函数};class Derived:public Base{public:x,y;void SetVal(int a,int b){}int fun(){return x+y;}};void 【 】 SetVal(int a,int b){x=a;y=b;} //类Derived成员函数void main(){Derived d;cout<<d.fun()<<endl;}

在下列方法的定义中,正确的是 ( )A.public double x(){..;return false;}B.public static int x(double y){...}C.void x(doubled){...;return d}D.public static x(double a){..}

以下的程序的执行结果为? () public class Demo{  public double getHeight(){  return 171.0;  }  public int getHeight (){  return 171;  }  public static void main(String[] args){  Demo demo = new Demo();  System.out.println(demo.getHeight());  }  } A、输出171.0B、输出171C、第2行和第5行编译报错D、第10行编译报错

给定java代码如下所示,在A处新增下列()方法,是对cal方法的重载。public class Test {  public void cal(int x, int y, int z) { } //A } A、public int cal(int x,int y,float z){return 0;}B、public int cal(int x,int y,int z){return 0;}C、public void cal(int x,int z){}D、public viod cal(int z,int y,int x){}

执行以下代码后,下面哪些描述是正确的() public  class  Student{  private String name = “Jema”;  public void setName(String name){  this.name = name;  }  public String getName(){  return this.name;  }  public static void main(String[] args){  Student s;  System.out.println(s.getName()); } }A、输出nullB、第10行编译报错C、第11行编译报错D、输出Jema

class super {   public float getNum() {return 3.0f;}   }   public class Sub extends Super {   }   Which method, placed at line 6, will cause a compiler error?()A、 Public float getNum() {return 4.0f; }B、 Public void getNum (){}C、 Public void getNum (double d){}D、 Public double getNum (float d) {retrun 4.0f; }

1. public class A {  2. public void doit() {  3. }  4. public String doit() {  5. return “a”;  6. }  7. public double doit(int x) {  8. return 1.0;  9. }  10.}  What is the result?() A、 An exception is thrown at runtime.B、 Compilation fails because of an error in line 7.C、 Compilation fails because of an error in line 4.D、 Compilation succeeds and no runtime errors with class A occur.

public class Parent{   public void change(int x){}  }   public class Child extends Parent{   //覆盖父类change方法   }   下列哪个声明是正确的覆盖了父类的change方法?() A、 protected void change(int x){}B、 public void change(int x, int y){}C、 public void change(String s){}D、 public void change(int x){}

public class SyncTest {  private int x;   private int y;   public synchronized void setX (int i) (x=1;)   public synchronized void setY (int i) (y=1;)   public synchronized void setXY(int 1)(set X(i); setY(i);)   public synchronized Boolean check() (return x !=y;)   }   Under which conditions will check () return true when called from a different class? A、 Check() can never return true.B、 Check() can return true when setXY is called by multiple threads.C、 Check() can return true when multiple threads call setX and setY separately.D、 Check() can only return true if SyncTest is changed to allow x and y to be set separately.

public class X {  public X aMethod() { return this;}  }  public class Y extends X {  }  Which two methods can be added to the definition of class Y?()A、 public void aMethod() {}B、 private void aMethod() {}C、 public void aMethod(String s) {}D、 private Y aMethod() { return null; }E、 public X aMethod() { return new Y(); }

class One {   public One foo() { return this; }  }  class Two extends One {  public One foo() { return this; }  }  class Three extends Two {   // insert method here  }  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; }

单选题1. public class A {  2. public void doit() {  3. }  4. public String doit() {  5. return “a”;  6. }  7. public double doit(int x) {  8. return 1.0;  9. }  10.}  What is the result?()A An exception is thrown at runtime.B Compilation fails because of an error in line 7.C Compilation fails because of an error in line 4.D Compilation succeeds and no runtime errors with class A occur.

多选题Which are syntactically valid statement at// point x?()     class Person {     private int a;  public int change(int m){  return m;  }     }  public class Teacher extends Person {     public int b;  public static void main(String arg[]){     Person p = new Person();     Teacher t = new Teacher();    int i;  // point x     }    }Ai = m;Bi = b;Ci = p.a;Di = p.change(30);Ei = t.b.

单选题10. interface Foo { int bar(); }  11. public class Sprite {  12. public int fubar( Foo foo) { return foo.bar(); }  13. public void testFoo() {  14. fubar(  15. // insert code here  16.);  17. }  18. }  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 newFoo() { public int bar(){return 1; } }D new class Foo { public int bar() { return 1; } }

单选题public class Parent{     public void change(int x){} }  public class Child extends Parent{     //覆盖父类change方法  }  下列哪个声明是正确的覆盖了父类的change方法?()A protected void change(int x){}B public void change(int x, int y){}C public void change(String s){}D public void change(int x){}

单选题1. class Super {  2. public float getNum() { return 3.0f; }  3. }  4.   5. public class Sub extends Super {  6.   7. }  Which method, placed at line6, causes compilation to fail?()A public void getNum(){}B public void getNum(double d){}C public float getNum() { return 4.0f; }D public double getNum(float d) { return 4.0d; }

多选题public class X {  public X aMethod() { return this;}  }  public class Y extends X {  }  Which two methods can be added to the definition of class Y?()Apublic void aMethod() {}Bprivate void aMethod() {}Cpublic void aMethod(String s) {}Dprivate Y aMethod() { return null; }Epublic X aMethod() { return new Y(); }

多选题public class NamedCounter {  private final String name;  private int count;  public NamedCounter(String name) { this.name = name; }  public String getName() { return name; }  public void increment() { coount++; }  public int getCount() { return count; } public void reset() { count = 0; } }  Which three changes should be made to adapt this class to be used safely by multiple threads? ()Adeclare reset() using the synchronized keywordBdeclare getName() using the synchronized keywordCdeclare getCount() using the synchronized keywordDdeclare the constructor using the synchronized keywordEdeclare increment() using the synchronized keyword

单选题class super {   public float getNum() {return 3.0f;}   }   public class Sub extends Super {   }   Which method, placed at line 6, will cause a compiler error?()A Public float getNum() {return 4.0f; }B Public void getNum (){}C Public void getNum (double d){}D Public double getNum (float d) {retrun 4.0f; }

单选题以下的程序的执行结果为? () public class Demo{  public double getHeight(){  return 171.0;  }  public int getHeight (){  return 171;  }  public static void main(String[] args){  Demo demo = new Demo();  System.out.println(demo.getHeight());  }  }A输出171.0B输出171C第2行和第5行编译报错D第10行编译报错

单选题现有      public class Parentt      public void change (int x){)     )      public class Child extends Parent{     //覆盖父类change方法     }      下列哪个声明是正确的覆盖了父类的change方法?()A  protected void change (int x){}B  public void change(int x,  int y){}C  public void change (int x){}D  public void change (String s){}

单选题public class SyncTest {  private int x;   private int y;   public synchronized void setX (int i) (x=1;)   public synchronized void setY (int i) (y=1;)   public synchronized void setXY(int 1)(set X(i); setY(i);)   public synchronized Boolean check() (return x !=y;)   }   Under which conditions will check () return true when called from a different class?A Check() can never return true.B Check() can return true when setXY is called by multiple threads.C Check() can return true when multiple threads call setX and setY separately.D Check() can only return true if SyncTest is changed to allow x and y to be set separately.

多选题给定java代码如下所示,在A处新增下列()方法,是对cal方法的重载。public class Test {  public void cal(int x, int y, int z) { } //A }Apublic int cal(int x,int y,float z){return 0;}Bpublic int cal(int x,int y,int z){return 0;}Cpublic void cal(int x,int z){}Dpublic viod cal(int z,int y,int x){}