题目内容 (请给出正确答案)
[单选题]

(7-1)以下程序的运行结果是()。 class A{ A(){ System.out.print(10); } } public class Demo extends A { public static void main(String[] args) { new A(); new Demo(); } }

A.10

B.10 10

C.编译失败

D.程序可以正常运行,但没有输出内容

提问人:网友linuxwang 发布时间:2022-01-07
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
网友答案
查看全部
  • · 有5位网友选择 D,占比62.5%
  • · 有3位网友选择 A,占比37.5%
匿名网友 选择了D
[18.***.***.90] 1天前
匿名网友 选择了A
[107.***.***.143] 1天前
匿名网友 选择了D
[108.***.***.100] 1天前
匿名网友 选择了A
[246.***.***.216] 1天前
匿名网友 选择了D
[78.***.***.99] 1天前
匿名网友 选择了D
[118.***.***.215] 1天前
匿名网友 选择了D
[146.***.***.129] 1天前
匿名网友 选择了A
[113.***.***.112] 1天前
加载更多
提交我的答案
登录提交答案,可赢取奖励机会。
更多“(7-1)以下程序的运行结果是()。 class A{ A(…”相关的问题
第1题
阅读以下代码,输出结果应该是( )。public class TestArray{ public static void main (String[] args){ int[] a ; System.out.println("a=" + a); } }

A、代码得到编译,并输出“a=0”。

B、代码得到编译,并输出“a=null”。

C、由于a没有初始化,代码不能编译通过。

D、代码得到编译,但捕获到NullPointException异常。

点击查看答案
第2题
写出以下程序的运行结果( )。interface IDemo { void demoMethod(); } public class MyDemo { public void test(IDemo demo) { System.out.println("test method:"); demo.demoMethod(); } public static void main(String[] args) { MyDemo md = new MyDemo(); /*这里使用匿名内部类的方式将接口对象作为参数传递到test方法中去了*/ md.test(new IDemo() { public void demoMethod() { System.out.println("implement method"); } }); } }
点击查看答案
第3题
分析以下C#语句,注意类MyClass没有显式指定访问修饰符:namespace aaa { class MyClass { public class subclass { int i; } } } 该类MyClass的默认访问修饰符是( )。

A、private

B、protected

C、internal

D、public

点击查看答案
第4题
有下列程序,在横线添加; #include<iostream> using namespace std; class TestClass { public: TestClass (int n){number=n;} ______//拷贝构造函数 ~TestClass(){} private: int number; }; TestClass fun(TestClass p) { TestClass temp(P); return temp; } int main() { TestClsss obj1(10),obj2(0); TestClass obj3(obj1); obj2=fun(obj3); return 0; }

A.TestClass(TestClass &other){number=other.number;}

B.TestClass(TestClass other){number=other.number;}

C.TestClass(TestClass &other){number;}

D.TestClass(&other){number=other.number;}

点击查看答案
第5题
3、下面哪些方法置于指定位置会导致编译错误 public class J_Super { public float getNum(){ return 3.0f; } public class J_Sub extends J_Super{ //指定位置 } }

A、A public float getNum(){return 4.0f;}

B、B public void getNum(){}

C、C public void getNum(double d){}

D、D public double getNum(float d){return 4.0d; }

点击查看答案
第6题
【简答题】预测程序运行结果 class Student{ private int age; private String name; public Student(String name, int age){ this.name=name; this.age=age;} public void show(){ System.out.println(“name=” name+” age=”+age);} } public class StudentDemo{ public static void main(String []args){ Student s=new Student(); s.show();}}
点击查看答案
第7题
有如下的类模板定义:

template<typenameTYPE>

classMyClass{

TYPE n;

public:

MyClass(TYPE k);

};

其中构造函数MyClass用的值初始化数据成员n。因此在模板类体外,构造函数MyClass应定义______。

点击查看答案
第8题
下面程序定义一个线程对象myThread,并启动该线程,哪个选项是正确的?( )

A、Thread myThread = new Thread(); my Thread.Start();

B、Thread myThread = new Thread(new ThreadStart(Method)); myThread.Start();

C、Thread myThread = new Thread(new ThreadStart(Method)); myThread.Run();

D、Thread myThread = new Thread(); myThread.Run ();

点击查看答案
第9题
有以下定义的类及变量: class B{ public: B(){b=0;}; protected:: int b; }; class A:private B { public: int get(){return b;} }; B cB; A cA; int a; 则下面语句中正确的是 ( )

A、a=cA.b;

B、a=cA.get();

C、a=cB.b;

D、以上都不对

点击查看答案
第10题
(7-1)以下程序运行结果是( )。 class FatherX{ public Integer getX() { return new Integer(10); } } class Son extends FatherX{ public Double getX() { return new Double(20); } } public class Demo12 { public static void main(String[] args) { FatherX f=new FatherX(); Son s=new Son(); System.out.println(f.getX()+s.getX()); } }

A、30

B、30.0

C、30.000

D、编译失败

点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

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

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

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