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

有以下程序public class Sun{public static void main(string args[]){int a,b; for(a=1,b=1;a<=

有以下程序 public class Sun { public static void main(string args[ ]) { int a, b; for(a=1, b=1; a<=100; a++) { if(b>=10) break; if (b%3==1) { b+=3; continue; } } System.out.println(A) ; } } 执行后的输出结果是()。

A.101

B.6

C.5

D.4

提问人:网友yangtuzi2000 发布时间:2022-01-07
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
更多“有以下程序public class Sun{public s…”相关的问题
第1题
阅读下面程序段 class Student : Person { public override string ToString() { return ID + "\t" + Name; } static void Main() { Student s = new Student(); s.ID = 1; s.Name = "JSON"; PromptName <student> (s); } } public class Person { public int ID { get; set; } public string Name { get; set; } public static void PromptName <t> (T t) where T : Person { Console.WriteLine(t); } } 程序运行结果:

A、1 JSON

B、Student

C、Person

D、出错,约束条件受限

点击查看答案
第2题
补全toString方法,使其内容为“width=***,height=***”。 public class Rectangle{ private double width; private double height; public Rectangle(){} public Rectangle(double a, double b) { width=a;height=b; } public String toString(){ 代码 } }
点击查看答案
第3题
public class BMI { public String toString(double weight, double height){ double b = weight/(height*height); if(b < 20) return "偏瘦"; else if(b < 25) return "正常"; else if(b < 30) return "偏胖"; else if(b < 35) return "肥胖"; else if(b < 40) return "重度肥胖"; else return "极度肥胖"; } } 输入55.0,1.75,返回结果是()。
点击查看答案
第4题
以文本形式(非附件)提交GameAPI.java的代码,代码中应该设计5个宝箱问题
点击查看答案
第5题
编译并运行以下程序,以下描述哪个选项是正确的?( ) class A{ protected boolean equals(){ return super.equals(); } }

A、编译通过运行无异常

B、编译通过但运行时出错

C、行2出错,不能成功编译

D、不能成功编译,行3出错

点击查看答案
第6题
阅读以下说明和Java程序,将应填入(n)处的字句写在对应栏内

[说明]

以下程序的功能时三角形、矩形和正方形的面积输出。

程序由5个类组成:areatest是主类,类Triangle,Rectangle和Square分别表示三角形、矩形和正方形,抽象类Figure提供了一个计算面积的抽象方法。

[Java程序]

public class areatest {

public static viod main(string args[]){

Figure[]Figures={

New triangle(2,3,3),new rectangle(5,8),new square(5)

};

for(int i=0; i<Figures.length;i++){

system.out.println(Figures+"area="+Figures.getarea());

}

}

}

public abstract class figure {

public abstract double getarea();

}

public class rectangle extends (1) {

double height;

double width;

public rectangle (double height,double width){

this.height=height;

this.width=width;

}

public string tostring(){

return"rectangle:height="+height+",width="+width+":";

}

public double getarea(){

return (2)

}

}

public class square exends (3)

{

public square(double width){

(4);

}

public string tostring(){

return"square:width="+width":";

}

}

public class triangle entends (5)

{

double la;

double lb;

double lc;

public triangle(double la,double lb,double lc){

this.la=la;this.lb=lb;this.lc=lc;

}

public string tostring()(

return"triangle:sides="+la+","+lb+","+lc+":";

}

public double get area(){

double s=(la+lb+lc)/2.0;

return math.sqrt(s*(s-la)*(s-lb)*(s-lc));

}

}

点击查看答案
第7题
SimpleAdapter构造方法第三个参数的含义是()
点击查看答案
第8题
阅读以下说明和Java代码,将应填入____处的语句或语句成分写在答题纸的对应栏内。

【说明】某数据文件students.txt的内容为100名学生的学号和成绩,下面的程序将文件中的数据全部读入对象数组,按分数从高到低进行排序后选出排名前30%的学生。【Java代码】

点击查看答案
第9题
阅读以下说明和Java 码,将应填入(n)处的字名写在的对应栏内。

[说明] 编写一个完整的JavaApplet 程序使用复数类Complex 验证两个复数1+2i 和3+4i 相加产生一个新的复数4+6i。

复数类Complex 必须满足如下要求:

(1) 复数类Complex 的属性有:

RealPart: int 型,代表复数的实数部分

ImaginPart: int 型,代表复数的虚数部分

(2) 复数类Complex 的方法有:

Complex():构造函数,将复数的实部和虚部都置0

Complex (intr,inti):构造函数,形参r为实部的初值,i为虚部的初值。

ComplexeomplexAdd (Complexa):将当前复数对象与形参复数对象相加,所得的结果仍是一个复数值,返回给此方法的调用者

String ToString():把当前复数对象的实部、虚部组合成s+ bi 的字符串形式,其中a和b分别为实部和虚部的数据。

importjava. applet. * ;

importjava. awt. * ;

publicclassabcextends Applet

{

Complex a, b, c;

publi cvoid init()

{

a = newComplex(1,2);

b = newComplex(3,4);

c = newComplex();

}

publievoidpaint (Graphicsg)

{

(1)

g. drawstring(“第一个复数:” + a. toString(), 10,50);

g. drawstring(“第二个复数:” + b. toString(), 10,70 );

g. drawstring(“两复之和:” + c. toString(), 10,90);

}

}

class Complex

{

int RealPart;

int ImaginPart;

Complex() { (2) }

Complex(intr , inti)

{ (3) }

ComplexeomplexAdd (Complexa)

{

Complextemp = newComplex();

temp. BealPart = RealPart + a. BealPart;

(4)

returntemp;

}

public StringtoString()

{ return(RealPart + " + " + ImaginPart + " i "); }

}

点击查看答案
第10题
public class Catalog implements Iterable<catalogitem> { private ArrayList<catalogitem> items; public Catalog() { this.items = new ArrayList<catalogitem>(); } ...... public CatalogItem getItem(String code) { 补充代码,遍历容器items,如果从容器找到一个目录项目,其code与参数 code一致,则将该目录项返回,否则返回null } ...... }
点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

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

简答题官方微信公众号

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

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

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