class BaseClass{ private float x= 1.0f; protected void setVar (float f) {x = f;} } class SubClass extends BaseClass { private float x = 2.0f; //insert code here 16. } Which two are valid examples of method overriding?()
第1题:
N-ISDN是指?( )
A.BRI
B.PRI
第2题:
为完成下面的程序,应在划线处填入的语句是 #include<iostream> using namespace std; class Base { private: int x; public: Base (int i) { x=i; } ~Base(){} }; class Derived:public Base { public: ______________//完成类Derive构造函数的定义 }; int main() { Derived Obj; return 0; }
A.Derived(int i):Base(i){}
B.Derived(){}
C.void Derived (int i):Base(i){}
D.Derived(int i){Base(i);}
第3题:
在Visual FoxPro中,基类的最小属性集为Class、BaseClass、ClassLibrary和______。
第4题:
A.编译错误
B.200
C.100200
D.100
第5题:
12 一个给定的数值由左边开始升位到右边第 N 位,如
0010<<1 == 0100
或者
0001 0011<<4 == 0011 0000
请用 C 或者 C++或者其他 X86 上能运行的程序实现。
-----------------------------------------------------------------------------
-----------------------------------
附加题(只有在完成以上题目后,才获准回答)
In C++, what does "explicit" mean? what does "protected" mean?
explicit
C++ Specific
This keyword is a declaration specifier that can only be applied to
in-class constructor declarations. Constructors declared explicit will not
be considered for implicit conversions. For example:
class X {
public:
explicit X(int); //legal
explicit X(double) { //legal // ... }
};
explicit X::X(int) {} //illegal
An explicit constructor cannot take part in implicit conversions. It can
only be used to explicitly construct an object. For example, with the class
declared above:
void f(X) {}
void g(int I)
{
f(i); // will cause error
}
void h()
{
X x1(1); // legal
}
The function call f(i) fails because there is no available implicit
conversion from int to X.
Note It is meaningless to apply explicit to constructors with multiple
arguments, since such constructors cannot take part in implicit conversions.
END C++ Specific
protected
C++ Specific —>
protected: [member-list]
protected base-class
When preceding a list of class members, the protected keyword specifies
that those members are accessible only from member functions and friends of
the class and its derived classes. This applies to all members declared up
to the next access specifier or the end of the class.
When preceding the name of a base class, the protected keyword specifies
that the public and protected members of the base class are protected
members of the derived class.
Default access of members in a class is private. Default access of members
in a structure or union is public.
Default access of a base class is private for classes and public for
structures. Unions cannot have base classes.
For related information, see public, private, friend, and Table of Member
Access Privileges.
END C++ Specific
Example
// Example of the protected keyword
class BaseClass {
protected: int protectFunc();
};
class DerivedClass : public BaseClass
{ public:
int useProtect() { protectFunc(); } // protectFunc accessible from
derived class
};
void main()
{
BaseClass aBase;
DerivedClass aDerived;
aBase.protectFunc(); // Error: protectFunc not accessible
aDerived.protectFunc(); // Error: protectFunc not accessible in derived
class } How do you code an infinite loop in C?
第6题:
分析下列程序中类MyClass的定义class BaseClass{publicinti;}classMyClass:BaseClass//继承BaseClass{publicnewinti;}则下列语句在Console上的输出为_______.()MyClassy=newMyClass();BaseClassx=y;//父类指针x指向子类对象x.i=100;//操作父类i Console.WriteLine("{0},{1}"
A、0,0
B、100,100
C、0,100
D、100,0
第7题:
假设objtb是类MyTextBox的一个实例对象,类MyTextBox是基类TextBox的一个直
接子类,那么objtb对象的BaseClass属性值是_____。
第8题:
使用VC6打开考生文件夹下的工程test10_1,此工程包含一个源程序文件test10_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果为;
class Base
class D1
class D2
class D3
fin Base
源程序文件test10_1.cpp清单如下:
include<iostream.h>
class Base
{
public:
Base(){cout<<"class Base"<<endl;}
void f(){cout<<"f in Base"<<endl;}
};
class D1:virtual public Base
{
public:
D1(){cout<<"class D1"<<endl;}
void f(){cout<<"f in D1"<<endl;}
};
/*********found**********/
class D2:public Base
{
public:
D2(){cout<<"class D2"<<endl;}
/**********found**********/
class D3::public D1,public D2
{
public:
D3(){cout<<"class D3"<<endl;}
};
void main()
{
D3 d;
/**********found************/
d.f();
}
第9题:
当你编译运行下列程序代码,会得到什么结果?
private class Base{ Base(){ int i = 100; System.out.println(i); } }
public class Pri extends Base{ staticint i = 200;
public static void main(String argv[]){ Pri p = new Pri(); System.out.println(i); } }
A.这段代码不能通过编译
B.输出200
C.输出100和200
D.输出100
第10题:
ThenetworkadministratorisaddinganewN1KvtothevCenter,however,theadministratordoesnotseethenewswitchunderthenetworkingtabofvCenter.
TheadministratorissuesthefollowingcommandontheVSMtotroubleshoot:
VSM#showsvsconnections
connectionVC:
ipaddress:10.10.10.30
remoteport:80
protocol:vmware-vimhttps
certificatE.default
datacenternamE.DC1
DVSuuiD.67323050a6d24964-9e1c5f49e3af5599
configstatus:Disabled
operationalstatus:Disconnectedsyncstatus:-
version:-
Whenattemptingtofixtheissue,thefollowingerrorisseen:
VSM-PRI-188#conf
VSM-PRI-188(config)#svsconnectionVC
VSM-PRI-188(config-svs-conn)#connect
ERROR:[VMWARE-VIM]Extensionkeywasnotregisteredbeforeitsuse
Whatisthecauseoftheerror?()