阅读下列代码段 abstract class Person{ public Person(String n){ name=n; } public______String getDescription(); public String getName(){ } private String name; } 在下画线处应填入的修饰符是
A.static
B.abstract
C.protected
D.final
第1题:
有以下程序:
include <iostream>
include <string>
using nameSpace std;
class person
{
int age;
Char * name;
public:
person ( int i, Char * str )
{
int j;
j = strlen( str ) + 1;
name = new char[ j ];
strcpy( name, str );
age = i;
}
~person()
{
delete name;
cout<<"D";
}
void display()
{
cout<<name<<":"<<age;
}
};
int main()
{
person demo( 30,"Smith" );
demo.display();
return 0;
}
则该程序的输出结果为:【 】。
第2题:
给出下列的不完整的类代码,则下列的( )语句可以加到横线处。 class Person{ String name,department; int age public Person(String n){name=n;} public Person(String n,int a){name=n;age=a;} pubilc Person(String n,String d,int a) { _______________ department=d; } }
A.Person(n,a);
B.this(Person(n,a));
C.this(n,a);
D.this(name,age);
第3题:
给出下列的不完整的类代码,则下列的哪个语句可以加到横线处? class Person { String name,department; int age; public Person( String n ){ name = n;} public Person( String n,int a ) { name = n;age = a;} public Person( String n,String d,int a ) { _____________ department = d; } }
A.Person(n,a);
B.this(Person(n,a) );
C.this(n,a);
D.this(name,age);
第4题:
下列程序运行后的输出结果是( )。#include#includeusing namespace std;class Person{public:Person(string n):name(n) { cout<<'P'; }private:string name;};class Date{public:Date(int y=2012,int m=12,int d=21):year(y),month(m),day(d) { cout<<'D'; }
private:int year,month,day;};class Student:public Person{public:Student(string n,int y,int m,int d,char c):birthday(y,m,d),sex(c),Person(n) { cout<<'S'; }private:Date birthday;char sex;};int main(){Student stu1("Zhang",1990,10,1,'F');return 0}
A. S
B.PS
C.DPS
D.PDS
第5题:
给出下面不完整的类代码,则横线处的语句应该为( )。 class Person { String name,department; int age; public Person (Strings) {name=s;} public Person (String s,int
A.{name=s;age=a;} public Person (String n,String d,intA){ __________ department=d; } }A)Person (n,A);
B.this (Person(n,A));
C.this(n,A);
D.this(name,age);