public class returnIt (    returnType methodA(byte x, double

题目
单选题
public class returnIt (    returnType methodA(byte x, double y) (   return (short) x/y * 2;   )  )   What is the valid returnType for methodA in line 2?()
A

 Int

B

 Byte

C

 Long

D

 Short

E

 Float

F

 Double

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

第1题:

methodA(byte x,double y){return (short)x/y*2;}下划线上应填写的关键字是( )。

A、byte

B、double

C、short

D、float


答案:B

第2题:

Which will declare a method that is available to all members of the same package and can be referenced  without an instance of the class?()  

  • A、 Abstract public void methoda();
  • B、 Public abstract double methoda();
  • C、 Static void methoda(double d1){}
  • D、 Public native double methoda(){}
  • E、 Protected void methoda(double d1){}

正确答案:C

第3题:

下列程序的执行结果为【 】。include class Point{public:Point(double i, double j)

下列程序的执行结果为【 】。

include <iostream. h>

class Point

{

public:

Point(double i, double j) { x=i; y=j;}

double Area() const { return 0.0;}

private:

double x, y;

};

class Rectangle: public Point

{

public:

Rectangle(double i, double j, double k, double 1)

double Area() const {return w * h;}

private:

double w, h;

};

Rectangle: :Rectangle(double i, double j, double k. double 1): Point(i,j).

{

w=k, h=1

}

void fun(Point &s)

{

cout<<s. Area()<<end1;

}

void main( )

{

Rectangle rec(3.0, 5.2, 15.0. 25.0);

fun(rec)

}


正确答案:×
0 解析:注意本题不同于基类的指针指向派生类对象。Fun函数的形参是Point基类的引用。在可以用基类对象的地方,均可以用派生类替代,完成基类的行为。反之,在使用派生类对象的地方却不能用基类对象代替,这是因为派生类中的某些行为在基类对象中是不存在的。本题调用的是Point类对象的面积函数,其值永远为0。

第4题:

Which will declare a method that forces a subclass to implement it? () 

  • A、 Public double methoda();
  • B、 Static void methoda (double d1) {}
  • C、 Public native double methoda();
  • D、 Abstract public void methoda();
  • E、 Protected void methoda (double d1){}

正确答案:D

第5题:

public class TestA{    public void methodA() throws IOException{        //……    } }  public class TestB extends TestA{    public void methodA() throws EOFException{        //……   } }  public class TestC extends TestA{    public void methodA() throws Exception{        //……   } }  当编译类TestC的时候,结果是哪项?() 

  • A、 正常
  • B、 编译错误
  • C、 运行错误
  • D、 以上都不对

正确答案:B

第6题:

1. public class ReturnIt {  2. return Type methodA(byte x, double y) {  3. return (long)x / y * 2;  4. }  5. }  What is the narrowest valid returnType for methodA in line2?()  

  • A、 int
  • B、 byte
  • C、 long
  • D、 short
  • E、 float
  • F、 double

正确答案:F

第7题:

Which will declare a method that is available to all members of the same package and be referenced without an instance of the class?()

  • A、 abstract public void methoda ();
  • B、 public abstract double inethoda ();
  • C、 static void methoda (double dl) {}
  • D、 public native double methoda () {}
  • E、 protected void methoda (double dl) {}

正确答案:C

第8题:

有如下两个类定义: class XX{ private: double xl; protected: double x2; public: double x3; }; class YY:protected XX{ private: double yl; protected: double y2; public: double y3; 在类YY中保护成员变量的个数是( )。

A.1

B.2

C.3

D.4


正确答案:C
本题考查保护继承中派生类对基类的访问属性,在受保护继承中,基类的公用成员和保护成员在派生类中成了保护成员,所以基类的成员x2、x3变成了保护成员,派生类中的y2也是保护成员,所以共有3个保护成员。本题答案为C、

第9题:

Which two are valid declarations within an interface definition?() 

  • A、 void methoda();
  • B、 public double methoda();
  • C、 public final double methoda();
  • D、 static void methoda(double d1);
  • E、 protected void methoda(double d1);

正确答案:A,B

第10题:

在接口中以下哪条定义是正确的?()

  • A、void methoda();
  • B、public double methoda();
  • C、public final double methoda();
  • D、static void methoda(double d1);
  • E、protected void methoda(double d1);

正确答案:A,B

更多相关问题