以下程序运行后输出的结果是______。
public class exl7
{
public static void main(String args [])
{
int a = 0;
for(int j = 1; j <= 20; j++)
if(j%5 != 0)
a = a + j;
System.out.println (a);
第1题:
下列程序的运行结果是______。
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
第2题:
有以下程序: #include<iostream> using namespace std; Class A{ public: A(){tout{("A"} }; classB{public:B(){cout<<"B";>> classC:public A{ B b; public: C(){cout<<"C";} }; int main(){C obj;return 0;} 执行后的输出结果是( )。
A.CBA
B.BAC
C.ACB
D.ABC
第3题:
若有以下程序: #include <iostream> using namespace Std; class sample { int i; publiC: sample(){} void setvalue(int m) { i=m; } void fun(int m) { i+=m; } void disp() { cout<<i<<end1; } }; int main() { sample *ps; ps=new sample; ps->setvalue(20); ps->fun(5); ps->disp(); return 0; } 程序运行后,输出的结果是( )。
A.15
B.20
C.25
D.30
第4题:
以下程序运行后的输出结果是______。
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;
}
第5题:
若有以下程序: #include<iostream> using namespace std; class TestClass { public: void who(){cout<<"TestClass"<<endl;} }; class TestClass1:public TestClass { public: void who(){cout<<"TestClass1"<<endl;} }; int main() { TestClass *p; TestClass1 obj1; P=&obj1; P->who(); return 0; 则该程序运行后的输出结果是( )。
A.TestClass1
B.TestClass
C.0
D.无输出
第6题: