题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-15 21:53:26

[单项选择]设有如下程序:
#include <iostream.h>
class A

public:
int i;
display( )
cout<<"class A/n";
;
class B

public:
int i;
display( )
cout<<"class B/n";
;
class C:public:A, public:B

int j;
public:
int i;
show( )
j=i*i;display( );
;
void main( )

C demo;
demo.show( );

则主程序运行时,将( )。
A. 因为变量i的重复定义而报错
B. 因为对象demo间接调用display函数时产生歧义性而报错
C. 因为类定义的语法错误而不能运行
D. 没有语法错误,能够正常输出结果

更多"设有如下程序: #include <iostream.h> cla"的相关试题:

[填空题]

[程序]
#include
#include
class B{
public:
B(char *s){name=new char[strlen(s)+1];strcpy(name,s);}
virtual void print( ){cout<<"姓名;"<
protected:
char *name;
};
class P1:public B{
public:
P1(char *s,float g):B(s){x=g;}
void print(int i)
{ cout<<"姓名:"<年薪:"<万元。 /n";}
private:
float x;
};
class P2:public B{
public:
P2(char *s,int n):B(s){ num=n;}
void print( ){cout<<"姓名;"<月工资:"<元。/n";}
private:
int num;
};
void main(void)
{
B *p;
B x("张明");
P1 y("王虎",4.2);
P2 z("李建国",5000);
p=&x;p->print( );
p=&y;p->print( );
y.print(1);
p=&z;p->print( );
}
执行以上程序后输出的第二行是() ,第四行是()。


[单项选择]下列程序的输出结果是()
#include
class Myclass
public:Myclass(int i=0,intj=0)
x=i;
y=j;

void show( ) cout < < "x=" < < x < < " " < "y=" < < y < < end1;
void show( )const cout < < "x=" < < " " < < "y=' < < y < < end1;
privated:
int x; int y;

void main( )
Myclass my1(3,4);
const my2(7,8);
my1.show( );my2.show( );
A. x=4,y=3;x=7,y=8
B. x=3,y=4;x=7,y=8
C. x=7,y=8;x=4,y=3 
D. x=8,y=7;x=7,y=8
[单项选择]

有如下程序:
  #include
  using namespace std;
  public:
  AA( ){ cout<<’1’; }
  };
  class BB: public AA{
  int k;
  public:
  BB( ):k(0){ cout<<’2’; }
  BB(int n):k(n){ cout<<’3’;}
  }
  int main( ){
  BB b(4), c;
  return 0;
  }
  运行时的输出结果是


A. 1312
B. 132
C. 32
D. 1412
[单项选择]设有如下程序:
import java.util.*;
public class Sun

public static void main(String args[ ])

int score;
String a;
Random r=new Random( );
score=r.nextInt(4)+5;
switch(score)

case 0:
a="E";
break;
case 1:
a="D";
break;
case 2:
a="C";
break;
case 3:
a="B";
break;
default:
a="A";

System.out.println(A) ;


程序运行的结果是( )。
A. a="A"
B. aa"E" a="A"
C. a="E"
D. a="C/
[填空题]

[程序]

#include

class A{

public:

A(char *s){cout<
A( ){ };

};

class B:public A{ //L1

public:

B(char *s1,char *s2):A(s1)

{ cout<
};

class C : public A{ //L2

public:

C(char *s1,char *s2):A(s1)

{ cout<
};

class D:public B,public C{

public:

D(char *s1,char *s2,char *s3,char *s4):B(s1,s2),C(s1,s3)

{ cout<
};

void main(void)

{

D *ptr= new D("students","study","C++","hard");

delete ptr;

}

执行程序后共输出___(1)___行.

若分别将L1行改为;class B : virtual public A{ //L1

L2行改为:class C:virtual public A{ //L2

则执行程序后共输出___(2)___行。

[填空题]

设有如下程序:
Option Base 1
Private Sub Commandl Click( )
Dim arrl
Dim Min As Integer,i As Integer
arrl=Array(12,435,76,-24,78,54,866,43)
Min=()
For i=2 To 8
If arrl(i)<Min Then()
Next
Print"最小值是:";Min
End Sub
以上程序的功能是:用Array函数建立一个含有8个元素的数组,然后查找并输出该数组中各元素的最小值。请填空。


[单项选择]设有如下程序:
#include <iostream>
using namespace std;
class A

public:
int i;
display( )

cout<<"class A/n";

;
class B

public:
int i;
display( )

cout<<"class B/n";

;
class C : public A, public B

int j;
public:
int i;
show ( )

j = i * i;
display( );

;
int main( )

C demo;
demo.show( );
return O;

则主程序运行时将( )。
A. 因为变量i的重复定义而报错
B. 因为对象demo间接调用display()函数时产生二义性而报错
C. 因为类定义的语法错误而不能运行
D. 没有语法错误,能够正常输出结果
[单项选择]设有如下程序: Option Base 1 Private Sub Command1_Click( ) Dim a(10) As Integer Dim n As Integer n=InputBox(“输入数据”) If n<10 Then Call GetArray(a,n) End If End Sub Private Sub GetArray(b( )As Integer,n As Integer) Dim c(10) As Integer j=0 For i=1 To n b(i)=CInt(Rnd( )*100) If b(i)/2=b(i)/2 Then j=j+1 c(j)=b(i) End If Next Print j End Sub以下叙述中错误的是
A. 数组b的偶数被保存在数组c中
B. 程序运行结束时,在窗体上显示的是c数组中元素的个数
C. GetArray过程的参数n是按值传送的
D. 如果输入的数据大于10,则窗体上不显示任何信息
[单项选择]

设有如下程序
Option Base 1
Private Sub Form_Click( )
Dim a(5) As String , i As Integer
For i=1 To 5
a(i)=Chr(Asc(“A”)+i)
Call f(a,i)
Next i
End Sub
Sub f(ta( ) As String , n As Integer)
Dim i As Integer
For i=1 To
Print ta(i);
Next i
End Sub
对上述程序,以下叙述中正确的是()。


A. 程序有错,因为在过程f的定义中数组参数格式不正确
B. 程序可正常运行,输出内容的第一行是一个字母“A”
C. 程序可正常运行,输出内容的第一行是一个字母“B”
D. 程序可正常运行,输出内容的第一行是数字65
[单项选择]设有如下程序:
Private Sub Cimmand1_Click( )
Dim sum As Double,x As Double
Sum=0
n=0
For i=1 To 5
x=n/i
n=n+1
sum=sum+x
Next i
End Sub
该程序通过For循环来计算一个表达式的值,这个表达式是
A. 1+1/2+2/3+3/4+4/5
B. 1+1/2+1/3+1/4+1/5
C. 1/2+2/3+3/4+4/5
D. 1/2+1/3+l/4+1/5
[单项选择]设有如下程序:
Private Sub Command1_Click( )
Dim sum As Double, x As Double
sum=0
n=0
For i=1 To 5
x=n/i
n=n+1
sum=sum+x
Next
End Sub
该程序通过For循环计算—个表达式的值,这个表达式是 ______。
A. 1+1/2+2/3+3/4+4/5
B. 1+1/2+2/3+3/4
C. 1/2+2/3+3/4+4/5
D. 1+1/2+1/3+1/4+1/5
[单项选择]设有如下程序:
Option Base 0
Private Sub Form_Click( )
Dim a
Dimi As Integer
a=Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
For i=0 To 3
Print a(5-i);
Next
End Sub
程序运行后,单击窗体,则在窗体上显示的是______。
A. 4 3 2 1
B. 5 4 3 2
C. 6 5 4 3
D. 7 6 5 4
[单项选择]设有如下程序:
Option Base ( )
Private Sub Form_Click( )
Dim a
Dim i As Integer
a=Array(1,2,3,4,5,6,7,8,9)
For i=0 To 3
Print a(5-i);
Next
End Sub
程序运行后,单击窗体,则在窗体上显示的是( )。
A. 4 3 2 1
B. 5 4 3 2
C. 6 5 4 3
D. 7 6 5 4
[填空题]

设有如下程序:
Private Sub Form_Click( )
Dim n As Integer,s As Integer
n=8
s=0
Do
s=s+n
n=n-1
Loop While n>0
Print s
End Sub
以上程序的功能是()。程序运行后,单击窗体,输出结果为()。


[单项选择]

设有如下程序:
Private Sub Commandl_click( )
Dim c As Integer,d As Integer
c=4
d=InputBox("请输入一个整数")
Do While d>0
If d>c Then
c=c+1
End If
d=InputBox("请输入一个整数")
Loop
Print c+d End Sub
程序运行后,单击命令按钮,如果在输入对话框中依次输入1、2、3、4、5、6、7、8、9、 0,则输出结果是()


A. 12
B. 11
C. 10
D. 9
[单项选择]设有如下程序:
Private Sub Command1_Click( )
Dim C As Integer, d As Integer
c=4
d=InputBox("请输入一个整数")
Do While d>0
If d>c Then
c=c+1
End If
d=InputBox("请输入一个整数")
Loop
Print c+d
End Sub
程序运行后,单击命令按钮,如果在输入对话框中依次输入1、2、3、4、5、6、7、8、9、0,则输出结果是______。
A. 12
B. 11
C. 10
D. 9
[单项选择]设有如下程序:
Private Sub Command1_Click( )
Dim sum As Double,x As Double
sum=0
n=0
For i=1 To 5
x=n/i
n=n+1
sum=sum+x
Next i
End Sub
该程序通过For循环来计算一个表达式的值,这个表达式是( )。
A. 1+1/2+2/3+3/4+4/5
B. 1+1/2+1/3+1/4+1/5
C. 1/2+2/3+3/4+4/5
D. 1/2+1/3+1/4+1/5

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码