题目内容 (请给出正确答案)
[主观题]

以下内容在同一个源程序中: abstract class A { abstract int num(); } class TestA { public st

以下内容在同一个源程序中: abstract class A { abstract int num(); } class TestA { public static void f(A t) { System.out.println(t.num()); } public static void main(String[] args) { f(new A() { int num() { return 20; } } ); } } 程序运行的结果是输出()。

查看答案
如搜索结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能会需要:
您的账号:
发送账号密码至手机
发送
更多“以下内容在同一个源程序中: abstract class A…”相关的问题

第1题

有以下源程序: package test; public class ClassA { int x=20; static int y=6; public static void main(String args[]) { ClassB b=new ClassB(); b.go(10); System.out.println("x="+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } } 上述源程序文件的运行结果为( )。

A.x=10

B.x=20

C.x=6

D.编译不通过

点击查看答案

第2题

有以下源程序: package test; public class ClassA { int x=20; static int y=6; public static void main(String args[]) { ClassB b=new ClassB(); b.go(10); System.out.println("x="+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } } 上述源程序文件的运行结果为( )。

A.x=10

B.x=20

C.x=6

D.编译不通过

点击查看答案

第3题

有以下程序:

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) ;

}

程序执行后的输出结果是【 】。

点击查看答案

第4题

若有以下程序: #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.11

C.12

D.10

点击查看答案

第5题

下面程序的运行结果为

#include

class A

{

static int n;

public:

A(){n=1;}

A(int num){n=num;}

void print(){coot <

}

int A::n=2:

void main()

{

A a.b(3);

a.print();

b.pint();

cout <

}

A.11

B.13

C.23

D.33

点击查看答案

第6题

若有以下程序: #include 〈iostream〉 using namespace std; class A { private: int x; public: int z; void setx(int i) { x=i; } int getx () { return x; } }; class B : public A { private: int m; public: int p; void setvalue(int a,int b, int C) { setx (A) ; z=b; m=c; } void display() { cout〈〈getx()〈〈","〈〈z〈〈","〈〈m〈〈end1; } }; int main ( ) { B obj; obj.setvalue(2,3,4); obj.display(); return 0; } 程序运行以后的输出结果是( )。

A.产生语法错误

B.2,3,4

C.2,2,2

D.4,3,2

点击查看答案

第7题

有以下程序: #include <iostream> using namespace std; class A { private: int a; public: A (int i) { a=i; } void disp() { cout<<a<<","; } }; class B { private: int b; public: B(int j) { b=j; } void disp() { cout<<b<<","; } }; class C : public B,public A { private: int c; public: C(int k) :A(k-2),B(k+2) { c=k; } void disp () { A::disp (); B::disp (); cout<<c<<endl; } }; int main () { C obi (10); obj.disp (); return 0; } 程序执行后的输出结果是

A.10,10,10

B.10,12,14

C.8,10,12

D.8,12,10

点击查看答案

第8题

下面程序的运行结果为 #include<iostream.h> class A { int num; public: A(int){num=i;} A(ABm){num=a.num++;} void print(){cout<<num;} }; void main() { Aa(1),b(a); a.print(); b.print(); }

A.11

B.12

C.21

D.22

点击查看答案

第9题

若有以下程序 #include <iostream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp() { cout<<a<<","; } }; class B { private: int b; public: B(int j) { b=j; } void disp() { cout<<b<<","; } }; class C: public B,public A { private: int c; public: C(int k):A(k-2),B(k+2) { c=k; } void disp() { A::disp(); B::disp(); cout<<c<<end1; } }; int main() { C obj(10); obj.disp(); return 0; } 程序执行后的输出结果是

A.10,10,10

B.10,12,14

C.8,10,12

D.8,12,10

点击查看答案

第10题

若有以下程序: #include <iostream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp() { cout<<a<<", "; } }; class B { private: int b; public: B(int j) { b=j; } void disp() { cout<<b<<", "; } }; class C : public B,public A { private: int c; public: C int k) :A(k-2),B(k+2) { c=k; } void disp() { A: :disp (); B::disp(); cout<<c<<end1; } }; int main () { C ebj (10); obj .disp (); return 0; } 程序执行后的输出结果是( )。

A.10,10,10

B.10,12,14

C.8,10,12

D.8,12,10

点击查看答案
热门考试 全部 >
相关试卷 全部 >
账号:
你好,尊敬的上学吧用户
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
谢谢您的反馈

您认为本题答案有误,我们将认真、仔细核查,
如果您知道正确答案,欢迎您来纠错

警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
上学吧
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反上学吧购买须知被冻结。您可在“上学吧”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
上学吧
点击打开微信