下列 Python语句的程序运行结果为 class A: def __init__(self,a, b, c): self.x=a+ b + c a= A(6, 2, 3); b= getattr(a,'x'); setattr(a,'x',b+1);print(a.x)
第1题:
下列程序段的显示结果为______。 x=0 Print x-1 x=3
A.-1 1
B.3
C.2
D.0
第2题:
下列程序的执行结果是( )。 #include<iostream.h> #include<stdlib.h> Class TestClass { public: int x,y; TestClass(){x=y=0;} TestClass(int a,int b){x=a;y=b;} void disp() { cout<<"x="<<x<<",y="<<y<<end1; } }; void main() { TestClass s1(2,3); s1.disp(); }
A.x=2,y=2
B.x=3,y=3
C.x=2,y=3
D.x=3,y=2
第3题:
下列程序的运行结果为 #include<iostream.h> class Location { protected: int X,Y; publiC: void SeX(int myx){X=myx;} void SetY(int myy){Y=myy;} void showxy( ) {cout<<"X=" <<X<<" " <<"Y"=<< Y<< endl;} }; Class Rectangle :public Location{
A.X=3 Y=5 X=3 Y=5 H=4 W=6
B.X=3 Y=5 X=3 Y=5 H=3 W=6
C.X=3 Y=5 X=3 Y=4 H=4 W=6
D.X=3 Y=5 X=3 Y=3 H=4 W=6
第4题:
有以下程序:
include<iostream.h>
class A
{
int x;
public:
A(int a)
{
x=a;
}
friend class B;
}
class B{
public:
void print(A a){
a. x--;
cout<<a.x<<end1;
}
};
void main()
{
A a(10);
B b;
b.print(a) ;
}
程序执行后的输出结果是【 】。
第5题:
下列程序的执行结果是( )。 #include<iostream.h> #include<stdlib.h> class TestClass { public: intx,y; TestClass(){x=y=0;} TestClass(int a,int b){x=a;y=b;} void disp() { cout<<"X"="<<X<<",y="<<y<<endl; }
A.x=2,y=2
B.x=3,y=3
C.x=2,y=3
D.x=3,y=2
第6题:
有如下程序: #include <iostream.h> class x { protected: int a; public: x() { a=1; } }; class x1 : virtual public x { public: x1() { a+=1; cout<<a; } }; class x2 : virtual public x { public: x2() { a+=2; cout<<a; } }; class y : public xl,public x2 { public: y() { cout<<a<<end1; } }; int main() { y obj; return O; } 该程序运行后的输出结果是( )。
A.1
B.123
C.242
D.244
第7题:
有以下源程序: package test; public class ClassA { int x=20; static int y=6; public static void main(String args[]) { ClassB b=new ClassB(); b.go(10); System.out.println("x="+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } } 上述源程序文件的运行结果为( )。
A.x=10
B.x=20
C.x=6
D.编译不通过
第8题:
有以下程序: #include 〈iostream〉 using namespace std; class A { public: virtual void setx(int i,int j=0) { x=i; y=j; } virtual void print()=0; protected: int x,y; }; class B : public A { public: void print() { cout〈〈x*x〈〈", "; } }; class C : public A { public: void print() { cout〈〈x*x*x〈〈end1; } }; int main() { A *pa; B b; C c; pa=&b; pa->setx(5); pa->print (); pa=&c; pa->setx(2); pa->print(); return 0; } 程序运行后的输出结果是( )。
A.25,8
B.2,5
C.5,2
D.8,25
第9题:
下列关于Python2.x和Python3.x的说法,正确的是()。
第10题:
在Python3.x中语句print(*[1,2,3])不能正确执行。
第11题:
第12题:
编译失败
falsefalsetruetruetruetrue
truetruetruetruetruetrue
falsefalsetruetruetruefalse
truefalsetruefalsefalsetrue
运行时异常被抛出
第13题:
下列程序的输出结果是【 】。
include <iostream>
using namespace std;
class A {
int a;
public:
A():a(9){}
virtual void print() const { cout<<a;};
};
class B: public A {
char b;
public:
B( ){b='S';}
void print() const {cout<<b;}
};
void show(A &x){ x.print0;}
int main()
{ Ad1,*p;
B d2;
p=&d2;
d1.print();
d2.print0;
p->print();
show(d1);
show(d2);
return 0;}
第14题:
下面程序的运行结果是( )。#include<iostream.h>class Sample{int x, y;public:Sample() { x=y=0; }Sample(int a, int b) { x=a; y=b; }void (lisp(){cout<<"x="<<x<<",y="<<y<<end1;}};void main(){Sample s(2,3), *p=&s;p->disp();}
A.x=1, y=2
B.x=2, y=4
C.x=2, y=3
D.x=4, y=3
第15题:
有如下程序: #include<iostream> using namespace std; class TestClass { private: int x,y; public: TestClass (int i,int j) { x=i; y=j; } void print() { cout<<"print1"<<end1; } void print()const { cout<<"print2"<<end1; } }; int main() { const TestClass a(1,2); a.print(); return 0; } 该程序运行后的输出结果是( )。
A.print1
B.print2
C.print1 print2
D.程序编译时出错
第16题:
下面程序的输出结果是
#include<iostream.h>
class example
{
int a;
public:
example(int b) {a=b++;}
void pnnt( ) {a=a+1;cout < < a < <" ";}
void print( ) const{cout < < a < <" ";}
};
void main( )
{
example x(3) ;
const example y(2) ;
x.print( ) ;
y.print( ) ;
}
A.2 2
B.4 3
C.4 2
D.3 2
第17题:
有以下程序:#include <iostream>using namespace std;class sample{private: int x; static int y;public: sample(int a); static void print(sample s);};sample:: sample(int a){ x=a; y+=x;}void sample:: print(sample s){ cout<<"x="<<s. x<<",y="<<y<<end1;}int sample:: y=0;int main(){ sample s1(10); sample s2(20); sample:: print(s2); return 0;}程序运行后的输出结果是( )。
A.x=10,y=20
B.x=20,y=30
C.x=30,y=20
D.x=30,y=30
第18题:
有如下程序: #include<iostreanl> using namespace std; class MyClass{ public: MyClass(int x):val(x){ } void Set(int x){val=x;} void Print( )eonst{eout<<"val="<<val<<'\t';} private: int val; }; int main( ){ eonst MyClass objl(10); MyClass obj2(20); objl.Print(); //语句1 obj2.Print( ); //语句2 objl.Set(20); //语句3 obj2.Set(30); //语句4 return 0; } 其主函数中错误的语句是
A.语句1
B.语句2
C.语句3
D.语句4
第19题:
运行下列程序:
Dim b
Private Sub Form_Click( )
a = 1: b = 1
Call fun1(a)
Print "X = "; a; ",Y = "; b
End Sub
Private Sub fun1(a)
b = 2 * a
a = 3 * b
End Sub
单击窗体后,则在窗体上显示的结果是( )。
A.X = 1,Y = 1
B.X = 2,Y = 6
C.X = 6,Y = 2
D.X = 6,Y = 1
第20题:
Python3.x语句print(1,2,3,sep=’:’)的输出结果为()。
第21题:
Python 3.x和Python 2.x唯一的区别就是:print在Python 2.x中是输出语句,而在Python 3.x中是输出函数。
第22题:
对
错
第23题:
对
错
第24题:
Python3.x使用print语句输出数据
Python3.x默认使用的编码是UTF-8
Python2.x和Python3.x使用//进行除法运算的结果不一致
Python3.x版本的异常可以直接被抛出