下列程序的执行结果是______。 public class ex3 { public static void main(String[] args) { int sum=0; for(int i=1;i<=100;i++) { sum+=i; } System.out.println("sum="+sum); }
A.sum=5050
B.sum=4950
C.sum=100
D.sum=1
第1题:
下列程序的运行结果是【 】。
include <iostream. h>
class SomeClass
{
public:
SomeClass(int value) { some_value=value;};
void show_data(void) { cout<<data<<"<<~some_value<<endl; };
static void set_data(int value) {data=value; }
private:
static int data;
int some_value
};
int SomeClass::data
void main(void)
{
SomeClass my_class(1001),your_class(2002);
your_class. set_data(4004);
my_elass. show_data()
}
第2题:
以下程序的执行结果是______。
include<iostream.h>
class base
{
public:
virtual void who(){cout<<"base class"<<endl:}
};
class derrvel:public base
{
public:
void who(){cout<<"derivel class"<<endl:}
};
class derive2;public base
{
public:
void who() {cout<<"derive2 class"<<endl;}
};
void main()
{
base obj1,*P;
derive1 obj2;
derive2 obj3:
p=&obj1;
p->who();
p=&obj2:
p->who();
p=&obj3;
p->who();
}
第3题:
第4题:
下列程序的运行结果是______。
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
第5题:
第6题:
main方法是Java应用程序执行的入口点,下面main方法的方法头合法的是()
A.public static void main()
B.public static void main(String[] args)
C.public static void Main(String[] args)
D.public static int main(String[] args)