多选题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

题目
多选题
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(); }

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

阅读下面程序 public class My Val{ public static void main(String args[]){ My Val m=new My Val(); m. amethod(); } public void amethod(){ boolean b[]=new Boolean[5]; } } 程序编译或运行结果是

A.1

B.null

C.

D.编译不能过


正确答案:C
解析:编译能通过,但不在控制台输出任何信息。程序只是实例化了一个布尔类型的数组,且由于此数组为局部变量,不会自动初始化,故其中值都为null。

第2题:

下列代码的编译或执行结果是( )。 public class Myval{ public static void main(string args[]){ MyVal m=new MyVal; aMethod; } public void aMethod{ boolean b[]=new Boolean[5]; System.OUt.println(b[0]); } }

A.1

B.null

C.0

D.编译错误


正确答案:A
A。【解析】boolean类型的变量值只有ture或false,b[0]的默认初始值为false。

第3题:

下列代码的编译或执行结果是______。

public class MyVal{

puhlic static void main(String args[]){

MyVal m=new MyVal();

m.aMethod();

}

public void aMethod(){

boolean b[]=new Boolean[5];

System.out.println(b[0]);

}

A) 1

B) null

C) 0

D) 编译错误

A.

B.

C.

D.


正确答案:B

第4题:

以下程序的运行结果为?

class ValHold{

public int i = 10;

}

public class ObParm{

public static void main(String argv[]){

ObParm o = new ObParm();

o.amethod();

}

public void amethod(){

int i = 99;

ValHold v = new ValHold();

v.i=30;

another(v,i);

System.out.print( v.i );

}

public void another(ValHold v, int i){

i=0;

v.i = 20;

ValHold vh = new ValHold();

v = vh;

System.out.print(v.i);

System.out.print(i);

}

}

A.10030

B. 20030

C. 209930

D. 10020


正确答案:D

第5题:

以下的程序的调试结果为?public class MyAr{public static void main(String argv[]) {MyAr m = new MyAr();m.amethod();}public void amethod(){static int i;System.out.println(i);}}

A. 输出结果为 0

B. 运行出错

C. 输出结果为 null

D. 编译错误


正确答案:D

第6题:

类testl定义如下: public class test1 { public float amethod(float a,float b){ } }

A.public foat amethod(float a,float b,foat c){ }

B.public float amethod(float c,float d){ }

C.public int amethod(int a,int b){ }

D.private float amethod(int a,int b,int c){ }


正确答案:B

第7题:

下列代码的执行结果是( )。

public class Test{

public int aMethod( ){

static int i=0;

i++;

System.out.println(i):

}

public static void main (String args[]){

Trest test=new Test ( );

test aMethod( ):

}

}

A.编译错误

B.0

C.1

D.运行成功,但不输出

B.

C.

D.


正确答案:A

第8题:

下列程序的执行结果是 ( ) public class Test { public int aMethod() { satic int i=0; i++; System.out.println(i); } public static void.main(String args[]) { Test test=new Test(); test.aMethod(); }

A.编译错误

B.0

C.1

D.运行成功,但不输出


正确答案:A

第9题:

以下程序的编译和运行结果为?

abstract class Base{

abstract public void myfunc();

public void another(){

System.out.println("Another method");

}

}

public class Abs extends Base{

public static void main(String argv[]){

Abs a = new Abs();

A.amethod();

}

public void myfunc(){

System.out.println("My Func");

}

public void amethod(){

myfunc();

}

}

A.输出结果为 My Func

B.编译指示 Base 类中无抽象方法

C.编译通过,但运行时指示Base 类中无抽象方法

D.编译指示Base 类中的myfunc方法无方法体,没谁会喜欢该方法。


正确答案:A

第10题:

以下的程序的调试结果为public class Scope{int i;public static void main(String argv[]){Scope s = new Scope();s.amethod();}public static void amethod(){System.out.println(i);}}

A. 输出结果为:0

B. 无输出

C. 编译错误

D. 输出null


正确答案:C

更多相关问题