8、如下代码的运行结果是__________。str1='abcd' print(type(str1[0]))A.<class 'char'>B.<class 'int'>C.<class 'float'>D.<class 'str'>

8、如下代码的运行结果是__________。str1='abcd' print(type(str1[0]))

A.<class 'char'>

B.<class 'int'>

C.<class 'float'>

D.<class 'str'>


参考答案和解析
B

相关考题:

下列程序的输出结果是 ( )#includeusing namespace std;class A{int apublic:A():a(9){}virtual void print() const {cout};class B:public A{char b;public:B(){b= ‘S’;}void print()const{cout};void show(AaX){X,print()}int main(){ Ad1;*p;Bd2;p=d2;d1,print();d2,print();p-print();show(d1);show(d2);return 0;}

有如下程序: include using namespaee std;class Animal{ public: virtual char*g 有如下程序:include<iostream>using namespaee std;c lass Animal{public:virtual char*getType( )const{return"Animal";}virtual char*getVoice( )const{return"Voice";}};class Dog:public Animal{public:char*getType( )const{return"Dog";}char*getVoice( )eonst{return"Woof";}};void type(AnimalA) {cout<<a.getType( );}void speak(Animal A) {eout<<a.getVoice( );}int main( ){Dog d;type(D) ;cout<<"speak";speak(D) ;cout return 0;}程序的输出结果是______。

有如下程序: include using namespace std; class Monitor{ public: Monitor(cha 有如下程序:include<iostream>using namespace std;class Monitor{public:Monitor(char t):type(t){ }void Print( )const{cout<<"The type of monitor is"<<type private:char type;};class Computer{public:Computer(int i,char C) :______{}void Print( )const{eout<<"The computer is"<<id<<endl;mort.Print( );}private:int id;Monitor mon;};int main( ){const Computer myComputer(101,'B');myComputer.Print( );return 0;}请将程序补充完整,使程序在运行时输出:The computer is 101The type of monitor is B

( 11 )有如下程序:#includeiostreamusing namespace std;class Monitor{public:Monitor ( char t ) : type ( t ) {}void print ( ) const{cout"The type of monitor is"typeendl;}private:char type;};class Computer{public:Computer ( int i , char c ) : 【 11 】 {}void Print () const{cout"The computer is"idendl;mon.Print ( ) ; }private:int id;Monitor mon;};const Computer myComputer ( 101,'B' ) ;myComputer .Print ( ) ;return 0;}请将程序补充完整,使程序在运行时输出:The computer is 101'The type of monitor i.s 8

( 13 )有如下程序:#include iostreamusing namespace std;class GrandChild{public:GrandChild(){ strcpy (name,"Unknown"); }const char * getName()const { return name; }virtual char * getAddress()const=0;private:char name[20];};class GrandSon : public GrandChild{public:GrandSon{char *name} {}Char * getAddress() const { return "Shanghai";}};int main(){GrandChild *gs=new GrandSon("Feifei");coutgs-getName()" 住在 "gs-getAddress()endl;delete gs;return 0;}运行时的输出结果是 【 13 】 。

阅读下面程序public class ConcatTest{P ublic static void main(String[] args){S tring str1 = " abc " ;S tring str2 = " ABC " ;S tring str3 = str1.concat(str2);S ystem.out.println(str3);}}程序的运行结果是A)abcB)ABCC)abcABCD)ABCabc

有如下applet代码:import java.applet.*;import java.awt.*;public class MyApplet extends Applet{AA s;public void int(){s = new AA("Hello!", "I love JAVA.");}public void paint(Graphics g){g.drawString(s.toString(), 30, 50);}}class AA{String s1;String s2;AA(String str1, String str2){s1 = str1;s2 - str2;}public String toString(){return s1 + s2;}}运行后,窗口上将会出现什么,选择一个正确答案______。A.Hello!B.I love JAVA.C.Hello! I love JAVA.D.什么都没有

阅读下列函数说明和C函数,将应填入(n)处的字句写在对应栏内。[函数2.1说明]函数strcpy的功能是将字符串str2的内容复制到字符申str1。[函数2.1](1) strcpy (char *slr1, const char *str2){ char * temp;while( * str2!='\0') *cp++ =(2);(3)='\0';return str1;}[函数2.2说明]函数int strcmp(const char *str1, const char *str2)的功能是按字典序比较两个字符串str1和str2的大小。当str1<str2时返回-1,当str1>str2时返回1,否则返回0。[函数2.2]int strcmp(const char *str1, const char *str2){ while( *str1= =* str2) {if(* s1= =(4)) return 0;s1++;(5);}if( *str1<*str2) return -1;return 1;}

下列程序的输出结果是【】。 include using namespace std; class A {int a; public:A() 下列程序的输出结果是【 】。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;}

有如下程序:#includeiostreamusing namespace std;class Music{public:void setTitle(char*str){strcpy(title,str);}protected:char type[10];private:char title[20];};class Jazz:public Music{public:void set(char*str){strcpy(type,”Jazz”); //①strcpy(title,str); //②}};下列叙述中正确的是A.程序编译正确B.程序编译时语句①出错C.程序编译时语句②出错D.程序编译时语句①和②都出错

下面代码的运行结果是( )。 public class ConcatTest { public static void main (String[ ] args) { String str1 = "abc"; String str2 = "ABC"; String str3 = str1. coneat(str2); System. out. println(str3); } }A.abcB.ABCC.abcABCD.ABCabc

如下程序的输出结果是includeusing namespace std;class A{public:A( ){cout 如下程序的输出结果是 #include<iostream> using namespace std; class A{ public: A( ){cout<<"A";} }; class B{public:B( ){cout<<"B";}}; class C:public A{ B b; public: C( ){cout<<"C";} }; int main( ){C obj;return 0;}A.CBAB.BACC.ACBD.ABC

下列程序的运行结果是______。include class Base { public: void f(int x){cout 下列程序的运行结果是______。include<iostream.h>class Base{public:void f(int x){cout<<“Base:”<<x<<endl;});class Derived:public Base{public:void f(char*str){cout<<“Derived:”<<str<<endl;}};void main(void){Base*pd=ne

有如下程序:ncludeiostreamusing namespace std;class Animal{public:virtual char*getType()const{return“Animal”;}virtual char*getVoice()const{return“Voice”;}};class Dog:public Animal{public:char*getType()const{rgturn“Dog”;}char*getVoice()const{retum“Woof”;}};void type(AnimalA){couta.getType();}void speak(AnimalA){couta.getVoice();}int main(){Dog d.type(D);tout“speak”;speak(D);coutendl;return 0;}运行时的输出结果是【 】

阅读下面程序 public class ConcatTest { public static void main(String[] args) { String str1="abc"; String str2="ABC": String str3=str1.concat(str2); System.out.println(str3); } } 程序运行的结果是A.abcB.ABCC.abcABCD.ABCabc

有以下程序#include "stdio.h"main() { char str[]="tomeetme",str1[]="toseeyou"; char *p=str,*p1=str1; int i; for(i=0;i if(*(p+i)==*(p1+i)) putchar(*(p+i)); printf("\n");}程序的运行结果是A.to B.tomeetC.toeeD.程序段不能通过编译

以下程序运行后的输出结果是______。includeinclude usingnamespacestd;classY 以下程序运行后的输出结果是______。include <iostream>include <string>using namespace std;class Y;class X{int x;char *strx;public:X(int a, char *str){x=a;strx=new char[strlen(str)+1]strcpy (strx,str);}void show(Y ob);};class Y{prlvate:int y;char *stry;public:Y(int b,char *str){y=b;stry=new char[strlen(str)+1];strcpy(stry,str);}friend void X::show(Y ob);};void X::show{Y ob){cout<<strx<<",",cout<<ob.stry<<endl;}int main{{X a (10, "stringX");Y b (20, "stringY");a. show (b);renurn 0;}

有如下程序: include using namespace std; class TestClass { private: int x,y; pu 有如下程序: #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.print1B.print2C.print1 print2D.程序编译时出错

有以下程序: include class A { intx; public: A(int a) { x=a;} friend class B; 有以下程序: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) ;}程序执行后的输出结果是【 】。

阅读下列程序,写出程序的运行结果【】。 include void main() { charstr1[ ]: "Hello, 阅读下列程序,写出程序的运行结果【 】。include<iostream. h>void main() { char str1[ ]: "Hello, World?;char str2[100];int i=0;do{if (str1[i]>= 'a' str1[i]<= 'z' )str2[i]=str1[i]-32;elsestr2[i]=strl [i];i++;}while(strl[i]!='\0');str2[i]='\0';cout<<str1<<end1;cout<<str2<<end1;}

若有以下程序: include usingnamespace std; class Sample { private: const int n; 若有以下程序:include <iostream>using namespace std;class Sample{private:const int n;public:Sample(int i) :n(i) {)void print(){cout<<"n="<<n<<end1;}};int main(){sample a(10);a.print();return 0;}上述程序运行后的输出结果是【 】。

若有以下程序:include using namespace std;class A{protected: int a;public: A() { 若有以下程序: #include <iostream> using namespace std; class A { protected: int a; public: A() { a=10; } }; class A1 : public A { public: A1() { a=a+1; } }; class A2 : public A { public: A2 () { a=a+2; } }; class B : public A1,public A2 { public: B(){} void print() { cout<<a<<end1; } }; int main ( ) { B obj; obj.print(); return 0; } 程序运行后的输出结果是( )。A.产生语法错误B.11C.12D.10

有以下程序:include include using namespace std;class Y;class X{private 有以下程序: #include <iostream> #include <string> using namespace std; class Y; class X { private: int x; char *strx; public: X(int a, char *str) { x=a; strx=new char[strlen(str)+1]; strcpy(strx,str); } void show(Y ob) ; }; class Y { private: int y; char *stry; public: Y(int b,char *str) { y=b; stry=new char[strlen(str)+1]; strcpy(stry, str); } friend void X: :show(Y ob) ; }; void X: :show(Y ob) { cout<<strx<<", "; cout<<ob, stry<<end1; } int main ( ) { X a(10,"X"); Y b (20, "Y"); a. show(B) ; return 0; } 执行后的输出结果是( )。A.X,YB.a,bC.X,XD.Y,Y

有如下程序:includeusing namespaee std;class A{public:A(int i):rl(i){ }void prin 有如下程序: #include<iostream> using namespaee std; class A{ public: A(int i):rl(i){ } void print( ){cout<<'E'<<rl<<'-';} void print( )const}cout<<'C'<<rl*rl<<'-';} private: int rl; }; int main( ){ A al(2);eonst A a2(4); a1.print( );a2.print( ); return 0; } 程序的输出结果是A.运行时出错B.E2-C16-C.C4-C16-D.E2-E4-

如下程序的输出结果是includeincludeusing namespace std;class XCD{char* 如下程序的输出结果是 #include<lostream> #include<cstring> using namespace std; class XCD{ char*a; int b; public: XCD(char*aa,int bB) { a=new char[strlen(aA) +1]; strcpy(a,aA) ; b=bb; } char*Geta( ){return a;} int Getb( ){return b;} }; int main( ){ char*pl="abcd",*p2="weirong": int dl,6,d2=8; XCD x(pl,d1),y(p2,d2); cout<<strlen(x.Geta( ))+y.Getb( )<<endl; return 0; }A.12B.16C.14D.11

有如下程序: #includeiostroam using namespace std; class Base{ protected: Base{cout’A’;} Base(char C){coutc;} }; class Derived:public Base{ public: Derived(char C){toutC;} }; int main{ Derived dl(’B’); retum 0; } 执行这个程序的输出结果是( )。A.BB.BAC.ABD.BB

下列程序的输出结果是 ()。 #include  #include   main( ) {    int i=0;    char str1[10]=“1234”, str2[10]= “567”;    strcat(str1,str2);    while(str2[i++]!=‘/0’)     str2[i]=str1[i];    puts(str2);   }

填空题下列程序的输出结果是 ()。 #include  #include   main( ) {    int i=0;    char str1[10]=“1234”, str2[10]= “567”;    strcat(str1,str2);    while(str2[i++]!=‘/0’)     str2[i]=str1[i];    puts(str2);   }