Java认证考试

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、 pub

题目

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题:

有如下程序: include using namespaee std; class ONE{ public: virtual void f

有如下程序:

include <iostream>

using namespaee std;

class ONE{

public:

virtual void f( ){cout<<"1";}

};

class TWO:public ONE{

public:

TWO( )1 cout<<"2";}

{;

class THREE:public TWO{

public:

virtual void f( )}TWO::f( );cout<<"3";}

};

int main( ){

ONE aa,*P;

TWO bb;

THREE cc;

P=&cc;

p->f( );

return 0;

}

程序的输出结果是______。


正确答案:2213
2213 解析:TWO bb;调用TWO的构造函数打印2;THREE cc;调用继承类TWO的构造函数打印2;p->f( );调用类TREE的函数f( ),先显式调用TWO类的函数f( ),TWO中没有重新定义f( )函数,所以调用TWO的基类ONE的虚函数f( );打印1,然后再打印3,故答案为2213。

第2题:

22.I am in _________ .

A. Grade One

B. eight

C. my friend

D. Class One


正确答案:D
22.D【解析】从文中第四句可知.

第3题:

() in our class went to the new movie but no one enjoyed it very much.

A、Everybody

B、Everyone


参考答案:B

第4题:

有如下程序: include using namespace std; class ONE { public: virtual void f() {

有如下程序:

include <iostream>

using namespace std;

class ONE

{

public:

virtual void f() { cout << "1"; }

};

class TWO: public ONE

{

public:

TWO() { cout << "2"; }

};

class THREE: public TWO

{

public:

virtual void f() {TWO::f(); cout << "3"; }

};

int main()

{

ONE aa, *p;

TWO bb;

THREE cc;

p=&cc;

P->f();

return 0;

}

执行上面程序的输出是【 】。


正确答案:2213
2213

第5题:

Eponyms is a process that puts an existing word of one class into another class.()


参考答案:错误

第6题:

( 35 )有如下程序:

#include<iostream>

using namespace std;

class ONE{

int c;

public:

ONE ( ) : c ( 0 ) {cout<<1;}

ONE ( int n ) : c ( n ) {cout<<2;}

};

class TWO{

ONE onel;

ONE one2;

public:

TWO ( int m ) : one2 ( m ) {cout<<3;}

};

int main () t

TWO t ( 4 )

return 0

}

运行时的输出结果是

A ) 3

B ) 23

C ) 123

D ) 213


正确答案:C

第7题:

阅读下列代码 public class Test{ String s="One World One Dream"; public static void main(String args[]){ System. out. println(s); } } 其运行结果是

A.args

B.One World One Dream

C.s

D.编译时出错


正确答案:D
解析:字符串s没有被声明成静态的,题中当主函数调用打印函数输出s的内容时,Test类还没有被实例化,也就没有字符串常量s了。可将字符串s声明为static类型的,或者在打印字符前先实例化Test类,再打印这个对象中的字符串。

第8题:

有如下程序:

#include

using namespace std;

class ONE

{

public:

virtual void f(){cout<<"l";}

};

class TWO:public ONE

{

public:

TWO(){cout<<"2";}

};

class THREE:public TWO

{

public:

virtual void f(){TWO::f(); cout<<"3";}

};

int main()

{

ONE aa, *p;

TWO bb;

THREE cc;

p = &cc;

p->f();

return 0;

}

执行上面程序的输出是 【 11 】 。


正确答案:

第9题:

Lucy and Lily is both in Class One.()


参考答案: 错误

第10题:

one of the distinctive features about the british class system is that it has also retained a hereditary aristocracy. ()


参考答案:正确

更多相关问题