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

有以下代码:void f(int port) { return new Package(port) { private int pt = port; public getPort() { return pt; } }; } 以下哪句是正确的?

A.正常编译和运行

B.因为第2行而编译失败

C.因为第4行而编译失败

D.编译通过,但是运行到第3行出错

提问人:网友maoyao 发布时间:2022-01-07
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
网友答案
查看全部
  • · 有3位网友选择 B,占比33.33%
  • · 有3位网友选择 D,占比33.33%
  • · 有2位网友选择 A,占比22.22%
  • · 有1位网友选择 C,占比11.11%
匿名网友 选择了A
[163.***.***.153] 1天前
匿名网友 选择了A
[157.***.***.166] 1天前
匿名网友 选择了D
[218.***.***.75] 1天前
匿名网友 选择了B
[23.***.***.86] 1天前
匿名网友 选择了B
[114.***.***.140] 1天前
匿名网友 选择了D
[57.***.***.208] 1天前
匿名网友 选择了C
[250.***.***.22] 1天前
匿名网友 选择了B
[62.***.***.162] 1天前
匿名网友 选择了D
[95.***.***.145] 1天前
匿名网友 选择了A
[163.***.***.153] 1天前
匿名网友 选择了A
[157.***.***.166] 1天前
匿名网友 选择了D
[218.***.***.75] 1天前
匿名网友 选择了B
[23.***.***.86] 1天前
匿名网友 选择了B
[114.***.***.140] 1天前
匿名网友 选择了D
[57.***.***.208] 1天前
匿名网友 选择了C
[250.***.***.22] 1天前
匿名网友 选择了B
[62.***.***.162] 1天前
匿名网友 选择了D
[95.***.***.145] 1天前
加载更多
提交我的答案
登录提交答案,可赢取奖励机会。
更多“有以下代码:void f(int port) { retur…”相关的问题
第1题
【单选题】类Parent、Child定义如下: public class Parent{ public float aFun(float a, float b) throws IOException { } } public class Child extends Parent{ //第6行 } 将以下哪种方法插入行6是不合法的

A、float aFun(float a, float b){ }

B、public int aFun(int a, int b)throws Exception{ }

C、public float aFun(float p, float q){ }

D、public int aFun(int a, int b)throws IOException{ }

点击查看答案
第2题
int area( int length, int width ) { int s; s= length * width ; return s; } 有如上求长方形面积函数,正确的调用方法是( )。

A、c=area(1,2);

B、area(1);

C、c=area("12","34" );

D、area( );

点击查看答案
第3题
以下类中有静态成员,关于静态成员说法正确的是 class A { public: A(int a=0) : x(a){ } static void f1(){ ____________; }; private: int x; static int y; };

A、第6行可以填入: y++

B、第6行不能填 x++

C、静态成员 y 可以在类中直接初始化,无需在类外初始化

D、每一个类A的对象都有一个独立的 y 实例

E、所有类A的对象共享同一个 x 的实例

点击查看答案
第4题
关于以下代码说法正确的是(_____)。 class Student: def language(self): print ("All the students like Python") class Mary(Student): def work(self): print("Mary is programming") class Tom(Student): def language(self): print("Tom likes JAVA") mary = Mary() tom = Tom()

A、mary.language()会打印出All the students like Python

B、tom.language()会打印出All the students like Python

C、tom.work()会打印出Tom is programming

D、tom.language()会打印出Tom likes JAVA

点击查看答案
第5题
现有分数类: class Fraction { public: Fraction(int x, int y) {fenzi = x;fenmu = y;} private: int fenzi; int fenmu; };
点击查看答案
第6题
1) A commitment to respecting the participatory rights of young people is incompatible with the age-old tendency of adults to take decisions concerning young people in their absence. _________________________________________________________________________________
点击查看答案
第7题
以下语句有错吗?

public class Something{

void doSomething(){

private String S="";

int 1=s.length();

}

}

点击查看答案
第8题
interface Com{ public void speak(); } public class EE { public static void main(String args[]) { Com p= new Com() { public void speak() { System.out.println("p是接口变量"); } }; p.speak(); } }
点击查看答案
第9题
以下哪句正确描述了以下代码执行的情况?public class FlowAp extends Frame{ public static void main(String argv[]){ FlowAp fa=new FlowAp(); fa.setSize(400,300); fa.setVisible(true); } FlowAp(){ add(new Button("One")); add(new Button("Two")); add(new Button("Three")); add(new Button("Four")); }//End of constructor }//End of Application

A、一个窗口,里面有四个按钮,依次标着One到Four,放在窗口的四条边内

B、一个窗口,里面有四个按钮,依次标着One到Four,自顶向下依次排列

C、一个窗口,里面只有一个标着Four的按钮占据整个窗口

D、运行时刻错误,说程序没有指定LayoutManager

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

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

简答题官方微信公众号

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

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

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