网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

若有如下类定义: class B{ void funl(){} protected: double varl: public: void fun2(){} }; class D:public B{ protected: void fun3(){} }; 已知obj是类D的对象,下列语句中不违反类成员访问控制权限的是( )。

A.obj.funl();

B.obj.varl;

C.obj.fun2();

D.obj.fun3();


参考答案

更多 “ 若有如下类定义: class B{ void funl(){} protected: double varl: public: void fun2(){} }; class D:public B{ protected: void fun3(){} }; 已知obj是类D的对象,下列语句中不违反类成员访问控制权限的是( )。A.obj.funl();B.obj.varl;C.obj.fun2();D.obj.fun3(); ” 相关考题
考题 有如下程序:#includeusing namespace std;class Base{private:void funl() const{cout"funl";}protected:void fun2() const{cout"fun2";}public:void fun3() const{cout"fun3";}};class Derived:protected Base{public:void fun4() const{cout"fun4";}};int main(){Derived obj;obj.funl(); // ①obj.fun2(); // ②obj.fun3(); // ③obj.fun4(); // ④return 0;}其中有语法错误的语句是A . ①②③④B . ①②③C . ②③④D . ①④

考题 有如下程序:#includeusing namespace std;class Base{public:void funl(){cout"Base\n";}virtual void fun2(){cout"Base\n";}};class Derived:public Base{public:void funl(){cout"Derived\n";}void fun2(){cout"Derived\n";}};void f(Base B . {b.funl();b.fun2();}, lt;, /Pint main(){Derived obj;f(obj);return 0;}执行这个程序的输出结果是A . Base BaseB . Base DerivedC . Derived BaseD . Derived Derived

考题 ( 31 )若有如下类定义 :class B{void fun1(){}protected:double varl;public:void fun2(){}};class D:public B{protected:void fun3(){}};已知 obj 是类 D 的对象,下列句中不违反类成员访问控制权限的是A ) obj.funl();B ) obj.varl;C ) obj.fun2();D ) obj.fun3();

考题 若有如下类定义: class B { void fun1() { protected: double var1; public: void fun2() { }, class D: public B protected: void fun3() { };已知obj是类D的对象,下列语句中不违反类成员访问控制权限的是A.obj.fun1();B.obj.varl;C.obj.fun2();D.obj.fun3();

考题 有如下程序: include using namespace std; class B { public: 有如下程序: #include <iostream> using namespace std; class B { public: virtual void show() { cout<<"B"; } }; class D: public B{ public: void show() { cout<<"D"; } }; void fun1(B *ptr) { ptr->show();} void fun2(B ref) { ref. show();} void fun3(B b) {b.show();} int main() { B b,*p=new D; D d; fun1(p); fun2(b); fun3(d); return 0; }程序的输出结果是A.BBBB.BBDC.DBBD.DBD

考题 若有如下程序:includeusing namespace std;class TestClass{public:void who(){cout 若有如下程序: #include<iostream> using namespace std; class TestClass { public: void who(){cout<<“TestClass”<<endl;} }; class TestClassl:public TestClass { public: void who(){cout<<“TestClassl”<<endl; int main() { TestCA.TestClasslB.TestClassC.0D.无输出

考题 下列关于Test类的定义中,正确的是______。A) class Test implements Runnabte{public void run(){}public void someMethod(){}B) class Test implements Rnuuable{public void run();}C) class Test implements Rnuuable{public void someMethod();}D) class Test implements Rnuuable{public void someMethod();{}}A.B.C.D.

考题 下列哪个方法可用于创建一个可运行的类? ( )A.public class X implements Runable {public void run(){...,.,}}B.public class X implements Thread {public void run(){......}}C.public class X implements Thread {public int run(){……}}D.public class X implements Runable {protected void run(){.....}}

考题 已知如下类定义: class Base { public Base (){ //... } public Base ( int m ){ //... } protected void fun( int n ){ //... } } public class Child extends Base{ // member methods } 如下哪句可以正确地加入子类中?() A.private void fun( int n ){ //...}B.void fun ( int n ){ //... }C.protected void fun ( int n ) { //... }D.public void fun ( int n ) { //... }

考题 若有如下类定义: class B{ void fun1( ){} private: double varl; public: void fun2( ){ } }; class D:public B{ private: void fun3( ){ } }; 已知obj是类D的对象,下列语句中不违反类成员访问控制权限的是A.obj.fun1( );B.obj.varl;C.obj.fun2( );D.obj.fun3( );

考题 有如下程序:includeusing namespace std;class B{public:virtual void show( ){cout 有如下程序: #include<iostream> using namespace std; class B{ public: virtual void show( ){cout<<"B";} }; class D:public B{ public: void show( ){cout<<"D";} }; void funl(B*ptr){ptr->show( );} void fun2(Bref);ref.show( );} void fun3(B b){b.show( );} int nlain( ){ B b,*P=Dew D; D d; funl(p); fun2(b); fun3(d); return 0; } 程序的输出结果是A.BBBB.BBDC.DBBD.DBD

考题 有如下程序: #includeiostream using namespace std; class Base { public: void funl{cout”Base\n”;} virtual void fun2{eout”Base\n”;} }; class Derived:public Base{ public: void funl{eout”Derived、n”;} void fura{eout.”Derived\n”;} }; void f(BaseB.}b.funl;b.ftm2;} int main { Derived obj; f(obj); return 0; } 执行这个程序的输出结果是( )。A.Base BaseB.Base DerivedC.Derived BaseD.Derived Derived

考题 有如下程序: #inCludeiostream using namespaCe std; Class B{ publiC: virtual void show{Cout”B”;} }; Class D:publiC B{ . publiC: void show{Cout”D”;} }; void funl(B * ptr){ptr一show;} void fUN2(Bref){ref.show;} voidfhIl3(B B.{b.show;} int main { B b,* P=new D; D d; funl(P); fun2(B.; fun3(D); delete P; return 0; } 执行这个程序的输出结果是( )。A.BBBB.BBDC.DBBD.DBD

考题 有如下两个类定义: 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.1B.2C.3D.4

考题 有如下程序: include using namespace std; class Base { private: 有如下程序: #include<iostream> using namespace std; class Base { private: void funl()const {cout<<"funl";} protected: void fun2() const{cout<<"fun2";} public; void fun3() const {cout<<"fun3";} }; class Derived:protected Base { public; void fun4() const {cout<<"fun4";} }; int main() { Derived obj; obj.funl(); //① obj.fun2(); //② obj.fun3(); //③ obj.fun4(): //④ return 0; } 其中有语法错误的语句是A.①②③④B.①②③C.②③④D.①④

考题 有如下程序:includeusing namespace std;class B{public:Virtual void show(){cout 有如下程序: #include<iostream> using namespace std; class B{ public: Virtual void show(){cout<<“B”;} }; class D:publicB{ public: void show(){cout<<“D”;} }; void funl(B*ptr){ptr->show();} void{un2(Bref){ref.show();} voidA.BBBB.BBDC.DBBD.DBD

考题 有如下程序:nclude using namespace std;class Base{public:void fun1() {cout 有如下程序:#nclude <iostream>using namespace std;class Base{ public:void fun1() {cout << "Base\n"; }virtual void fun2() {cout << "Base\n"; }};class Derived: public Base{ public:void fun1() {cout << "Derived\n"; }void fun2() {cout << "Derived\n"; }} void f(Base b) { B. fun1(); B. fun2(); }int main(){Derived obj;f(obj);return 0;}A.Base BaseB.Base DerivedC.Derived BaseD.Derived Derived

考题 若类A和类B的定义如下: class A { public: int i,j; void get(); }; class B:A{ int i, j; protected; int k; public: void make(); }; void B: :make()(k=i*j;} 则其中 ______ 是非法的表达式。A.void get();B.int k;C.void make();D.k=i*j;

考题 若类A和类B的定义如下: class A { int i,j; public: void get(); //… } ; class B:A//默认为私有派生 { int k; public: void make(); //… }; void B::make() { k=i*j; } 则上述定义中, ( )是非法的表达式。A.void get();B.int k;C.void make();D.k=i*j;

考题 有如下类定义: class B { public:void funl{} private:void fun2{} protected:void fun3{} }; class D:public B j protected:void fun4{} }; 若obj是类D的对象,则下列语句中不违反访问控制权限的是( )。A.obj.fun1;B.obj.fun2;C.obj.tim3;D.ohj.fun4;

考题 有如下程序: #includeiostream using namespace std; class Base { private: void funlconst{tout”funl”;} protected: void fun2const{tout”fun2”;} public: void fun3const{cout”fhll3”;} }; class Derived:protected Base { public: void fhn4const{cout”filn4”;} }; int main { Derived obj; obj.funl;//① obj.fun2;//② obj.furd;//③ obj.fun4;//④ return U: } 其中有语法错误的语句是( )。A.①②③④B.①②③C.②③④D.①④

考题 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){}

考题 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) {}

考题 单选题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 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){}

考题 单选题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)  {}

考题 单选题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) {}