A.1
B.7
C.6
D.4
若vehicle=['train','bus','car','ship'],则vehicle[1]是什么?A.trainB.busC.carD.ship
点击查看答案
若vehicle=['train','car','bus','subway','ship','bicycle','car'],则vehicle.count('car')结果是什么?A.carB.7C.1D.2
若vehicle=[['train','car'],['bus','subway'],['ship','bicycle'],['car']],则len(vehicle[1][0])结果是什么?A.3B.7C.6D.4
若vehicle=['train','bus','car','ship'],则vehicle.index('car')的结果是什么?A.1B.2C.3D.4
若vehicle=[['train','car'],['bus','subway'],['ship','bicycle'],['car']],则len(vehicle[1])结果是什么?A.2B.7C.6D.4
阅读以下说明和C++代码,填充代码中的空缺,将解答填入答题纸的对应栏内。【说明】某应急交通控制系统(TraficControISy ,tem)在红灯时控制各类车辆(Vehicle)的通行,其类图如图5-1所示,在紧急状态下应急车辆红灯时也可通行,其余车辆按正常规则通行。下面的C++代码实现以上设计,请完善其中的空缺。include include using namespace std;class Vehicle {/*抽象基类,车辆*/public :virtual void run () = 0;};class Emergency( /*抽象基类,可在红灯时通行的接口,函数均为纯虚函数*/public:(1)=0 //isEmergent()函数接口(2)=0 //runRedLight()函数接口};class Car: public Vehicle {public :-car(){ }void run () { /*代码略*/ }};Ciass Truck:public vehicie {Public;-Truck(){ }Void run() { /*代码略*/}};Class policecar: (3) {Private:bool isEmergency;public :PoliceCar () : Car () , Emergency () { this=>isEmergency = false;}PoliceCar (bool b) : Car () , Emergency () { this=>isEmergency = b; }~PoliceCar () { }bool isEmergent () { ret irn (4) ; }void runRedLight () { /*代码略*/ }};/*类Ambulance. FireEngine/*实现代码略*/class TraficControISystem {/*交通控制类*/private :Vehicle*v[24]; int numVeh: cles./*在构造函数中设置初始值为0*/public:void control(){ //控制在紧急情况下应急车辆红灯通行,其他情况按常规通行for (int i = 0; iadd (new Car () );, t cs->add (new PoliceCar ()) ;tcs->add (new Ambulance ()) ; tcs- >add (new Ambulance (true)) ;tcs->add (new FireEngine (true)) ; -.cs->add (new FireEngine ()) ;tcs->add (new Truck ()) ;tcs->control () ; tcs->shul Down ( ) ;delete tcs;}
阅读以下说明和Java代码,填充程序中的空缺,将解答填入答题纸的对应栏内。【说明】某应急交通控制系统(TraficControIS,stem)在红灯时控制各类车辆(Vehicle)的通行,其类图如图6-1所示,在紧急状态下应急车辆在红灯时可通行,其余车辆按正常规则通行。下面的Java代码实现以上设计,请完善其中的空缺。【Java代码】abstract class Vehiclepublic Vehicle () { }abstract void run};interface Emergency {(1) ;(2) ;}class Car extends Vehicle {public Car () { }void run () { /*代码略*/ }};class Truck extends Vehicle {public Truck () { }void run () { /*代码略*/ }class PoliceCar (3)boolean isEmergency = false;public PoliceCar () { }public PoliceCar(boolean b) { this . isEmergency =b; }public boolean isEmergent () { return (4); }public void runRedLight () { /*代码略*/ }}/*类Ambulance. FireEngine实现代码略*/public class TraficControISystem {/。交通控制类。/private Vehicle[ ]V=new Vehiele [24];int numVehicles;public void control() {for (int i=0; i<numVehicles; i++) {if (v[i] instanceof Enu rgency&& ((Emergency)V [i])isEmergent()) {( 5 ) . runRedLigh&39;: ( ) ;}else(6).run( )}}void add (Vehicle vehicle) { v[numVehicles++]=vehicle;)/*添加车辆*/void shutDown()(/*代码略*/}public static void main (Stri.ng [ ] args) {TraficControlSystem tcs = new TraficControlSystem() ;tcs . add (new Car () ;tcs .add (new PoliceCar () ;tcs .add (new Ambulance () ;tcs . add (new Ambulance (true》 ;tcs . add (new FireEngine ( true》 ;tcs . add (new Truck () ;tcs . add (new FireEngine ( ) ;tcs . control () ;tcs . shutDown () ;}}