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

给出代码运行结果()

A.double x = 3 / 2 + 1

B.double y = 3 / (2+1)

C.x = 2.0 y = 1

D.x = 2.0 y = 1.0

E.x = 2.5 y = 1.0

F.x = 2.5 y = 1

查看答案
如搜索结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能会需要:
您的账号:
发送账号密码至手机
发送
更多“给出代码运行结果()”相关的问题

第1题

阅读以下说明和C++代码。[说明] 类Stock的定义中有三处错误,分别在代码的第04、06、10行。请补齐下述

阅读以下说明和C++代码。

[说明]

类Stock的定义中有三处错误,分别在代码的第04、06、10行。请补齐下述代码中的空缺(1),修改错误并给出修改后该行的完整代码,最后完善程序运行后的输出结果。

[C++代码]

01 include <iostream>

02 using namespace std;

03 class Stock{

04 protected:

05 Stock(){shares=0;share_val=0.0;Output();}

06 Stock(int n=0,double pr=3.5): (1) {//初始化shares值为n

07 share_val=pr;

08 Output();

09 };

10 void Stock(){};

11 void Output(){cout<<shares <<':'<<share_val<<end1;}

12 public:

13 //成员函数

14 private:

15 //成员变量

16 int shares;

17 double share_val;

18 };

19

20 void main(){ //构造三个Stock对象a,b,c

21 Stock a(1);

22 Stock b;

23 Stock c=Stock();

24 //其它代码省略,且代码五输出

25 }

程序运行后的输出结果为:

1:3.5

(2)

(3)

点击查看答案

第2题

阅读以下说明和C++代码,将解答写入对应栏内。 [说明] 类Stock的定义中有三处错误,分别在代码的

阅读以下说明和C++代码,将解答写入对应栏内。

[说明]

类Stock的定义中有三处错误,分别在代码的第04、06、10行。请补齐下述代码中的空缺(1)~(3),修改错误并给出修改后该行的完整代码,最后完善程序运行后的输出结果。

[C++程序]

01 include<iostream.h>

02 using namespace std;

03 class Stock{

04 protected:

05 Stock(){shares=0; share_val=0.0;Output();}

06 Stock(int n=0,double pr=3.5): (1) {//初始化shares值为n

07 share_val=pr;

08 Output();

09 };

10 void~Stock(){};

11 void Output()(cout<<shares<<';'<<share val<<endl;}

12 public:

13 //成员函数

14 private:

15 //成员变量

16 int shares;

17 double share_val;

18 };

19

20 void main(){ //构造三个Stock对象a,b,C

21 Stock a(1);

22 Stock b;

23 Stock C;Stock();

24 //其他代码省略,且代码无输出

25 }

程序运行后的输出结果为:

1:3.5

(2)

(3)

点击查看答案

第3题

阅读以下说明和C++代码。[说明]类Stock的定义中有三处...

阅读以下说明和C++代码。

[说明]

类Stock的定义中有三处错误,分别在代码的第04、06、10行。请补齐下述代码中的空缺(1),修改错误并给出修改后该行的完整代码,最后完善程序运行后的输出结果。

[C++代码]

01 include <iostream>

02 using namespace std;

03 class Stock{

04 protected:

05 Stock(){shares=0;share_val=0.0;Output();}

06 Stock(int n=0,double pr=3.5): (1) {//初始化shares值为n

07 share_val=pr;

08 Output();

09 };

10 void Stock(){};

11 void Output(){cout<<shares <<':'<<share_val<<end1;}

12 public:

13 //成员函数

14 private:

15 //成员变量

16 int shares;

17 double share_val;

18 };

19

20 void main(){ //构造三个Stock对象a,b,c

21 Stock a(1);

22 Stock b;

23 Stock c=Stock();

24 //其它代码省略,且代码五输出

25 }

程序运行后的输出结果为:

1:3.5

(2)

(3)

点击查看答案

第4题

试图编译和运行以下代码的结果是什么?class Base { void f(int i) {System.out.println("int");

试图编译和运行以下代码的结果是什么?class Base { void f(int i) {System.out.println("int"); } void f(double d) {System.out.println("double");} } public class Fin extends Base { void f(String s) { System.out.println("String"); } public static void main(String argv[]){ Fin a = new Fin(); a.f(10); } }

A、无法编译,因为Fin里只有接受String的f()

B、无法编译,因为Fin里的f()和Base类的两个f()都无法构成override关系

C、编译通过,打印出String

D、编译通过,打印出int

点击查看答案

第5题

[说明] 下面是一段java代码,运行结果如图11-8所示。 程序代码如下: (1)Java.awt.Graphics; (2)Ja

[说明] 下面是一段java代码,运行结果如图11-8所示。

程序代码如下:

(1)Java.awt.Graphics;

(2)Java.applet.Applet;

// ////////////////////////////////////////////

// Display y=sin(x)

public class J_DrawSin (2) Applet

{

public void paint(Graphics g)

{

double d, tx;

int x, y, x0, y0;

d=Math.PI/100; // Set step(Set the unit in x direction)

x0=y0=0;

(3)(tx=0, x=20; tx<2*Math.PI; tx+=d,x++)

{

y=120-(int)(Math.sin(tx)*50+60);

if(x>20)

g.drawLine(x0, y0, x, y);

x0=x;

y0=y;

}

g.drawstring("y=sin(x)", 10, 70);

} //End of method: paint

} //End of class: J_HelloApplet

<!-----------------------AppletExample.html------------------->

<HTML>

<HEAD>

<TITLE>

An applet Example ---- Hello Applet!

</TITLE>

</HEAD>

<BODY>

<(4)CODE="J_DrawSin.class" WIDTH=300 HEIGHT=120>

</APPLET>

</BODY>

</HTML>

把所缺代码补充完整。

点击查看答案

第6题

阅读以下说明和Java代码。[说明] 已知类Stock和类JavaMain都定义在JavaMain.java文件中,类Stock的

阅读以下说明和Java代码。

[说明]

已知类Stock和类JavaMain都定义在JavaMain.java文件中,类Stock的定义中有四处错误,分别在代码的第01、02、06、07行。请修改错误并给出修改后该行的完整代码,并写出改正错误后程序运行的输出结果。

[Java代码]

01 public class Stock{

02 static {

03 shares=0;

04 share_val=0.0;

05 }

06 private Stock(){getData();}

07 private Stock(int n, double pr=0){

08 shares=n;

09 share_val=pr;

10 getData();

11 }

12 public void getData(){

13 System.out.print(shares+":"+share_val+"");

14 }

15 private int shares; //非静态变量

16 private double share_val; //非静态变量

17 };

18

19 public class JavaMain{

20 public static void main(String args[]){

21 Stock a=new Stock();

22 Stock b=new Stock(1,67.5);

23 //其它代码省略,且代码无输出

24 }

25 }

点击查看答案

第7题

试图编译和运行以下代码的结果是什么?class Base { void f(int i) {System.out.println("int"); } void f(double d) {System.out.println("double");} } public class Fin extends Base { void f(String s) { System.out.println("String"); } public static void main(String argv[]){ Fin a = new Fin(); a.f(10); } }

A.无法编译,因为Fin里只有接受String的f()

B.无法编译,因为Fin里的f()和Base类的两个f()都无法构成override关系

C.编译通过,打印出String

D.编译通过,打印出int

点击查看答案

第8题

阅读以下说明和C++代码,填入(n)处。[说明] 以下C++代码使用虚函数实现了同一基类shape派生出来的C

阅读以下说明和C++代码,填入(n)处。

[说明]

以下C++代码使用虚函数实现了同一基类shape派生出来的Class rectangle、Class triangle、Class circle实现了计算矩形、圆形面积的计算。仔细阅读以下代码,将(n)处语句补充完整。

[代码5-1]

include<iostream.h>

define PI 3.14159

class shape {//基类

protected:

(1);

public:

(2);

(3);

};

[代码5-2]

class rectangle: public shape {

public:

rectangle (int x2,int y2,int r2): (4) {};

double area () {return x*y; };

};

class circle: public shape {

public:

circle (int x3,int y3,int r3):(5){};

double area () {return r*r*PI; };

};

[代码5-3]

void main ()

{

rectangle r (10,20,0);

circle c (0,0,30);

shape (6);

cout<<"长方形面积="<<s1->area () <<endl;

cout<<"圆形面积="<<s2->area () <<endl;

}

[运行结果]

长方形面积=200

圆形面积=2827.43

点击查看答案

第9题

如下程序,期望的功能是:输入两个实数和一个运算符(=-*/),输出运算结果。请运行如下程序,输入1.0 +
2.0,观察运算结果,分析原因,并程序调试成功,提交正确代码。 # include <stdio.h> int main(void) { char op; double x, y; scanf("%lf %c %lf", &x, &op, &y); switch(op) { case ’+’: printf("%.2f\n", x + y); case ’-’: printf("%.2f\n", x - y); case ’*’: printf("%.2f\n", x * y); case ’/’: printf("%.2f\n", x / y); default: printf("Wrong input\n"); } }

点击查看答案

第10题

分析下面的Java代码,该程序的运行结果是()class Check{public static void main(String args[
分析下面的Java代码,该程序的运行结果是()

class Check{

public static void main(String args[]){

double d =12.3;

Decrementer dec =new Decrementer();

dec.decrement(d);

System.out.println(d);

}

}

class Decrementer{

public void decrement(double decMe){

decMe=decMe-1.0;

}

}

A、 打印输出0.0

B、 打印输出-1.0

C、 打印输出12.3

D、 打印输出11.3

点击查看答案

第11题

请依次说出【代码1】-【代码2】的输出结果。注意:结果之间用英文的分号分隔 interface A{ double f(double x, double y); } class B implements A{ public double f(double x, double y){ return x*y; } int g(int a, int b){ return a+b; } } public class E{ public static void main(String args[]){ A a=new B(); System.out.println(a.f(3,5)); // 【代码1】 B b=(B)a; System.out.println(b.g(3,5)); // 【代码2】 } }
点击查看答案
热门考试 全部 >
相关试卷 全部 >
账号:
你好,尊敬的上学吧用户
发送账号至手机
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
谢谢您的反馈

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

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

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

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