网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
( 8 )阅读下列程序段
public class OperatorsAndExpressions {
String conditionalExpression ( int score ) {
String result;
//如果 score 超过 60 分,则结果是 passed, 否则是 doesn't pass
result= ( score>=60 ) ?"passed":"doesn't pass" :
System.out.println ( result ) ;
return result;
}
public static void main ( String args[] ){
OperatorsAndExpressions perAndExp=new OperatorsAndExpressionsQ;
//条件表达式
OperAndExp. conditionalExpression ( 65 ) ;
}
}
其执行结果是 【 8 】
参考答案
更多 “ ( 8 )阅读下列程序段public class OperatorsAndExpressions {String conditionalExpression ( int score ) {String result;//如果 score 超过 60 分,则结果是 passed, 否则是 doesn't passresult= ( score=60 ) ?"passed":"doesn't pass" :System.out.println ( result ) ;return result;}public static void main ( String args[] ){OperatorsAndExpressions perAndExp=new OperatorsAndExpressionsQ;//条件表达式OperAndExp. conditionalExpression ( 65 ) ;}}其执行结果是 【 8 】 ” 相关考题
考题
下列程序段中,A_class的成员函数Variance()可求出两数的平方差,请改写该程序段,把Variance()函数从A_class类中分离出来,用友元函数来实现该函数的功能。class A_class {private:intx,y,t;public:A_class(int i,int j):x(i),y(j) {if(yx){t=x;x=y;y=t;}}intVariance(){return x*x-y*y;}//其它函数从略};void main() {A_classA_obj(3,5);coutResult:A_obj.Variance()endl;}
考题
阅读下列程序段public class OperatorsAndExpressions {String conditionalExpression(int score) {String result;//如果score超过60分, 则结果是passed, 否则是doesn't passresult=-(score>=60)?"passed":"doesn't pass";System.out.println(result);retum result;}public static void main(String args[]) {OperatorsAndExpressions perAndExp=new OperatorsAndExpressions();//条件表达式OperAndExp.conditionalExpression(65);}}其执行结果是【 】 。
考题
下列程序的运行结果是【 】。 include class SomeClass { public: SomeClass(int va
下列程序的运行结果是【 】。include <iostream. h>class SomeClass{public:SomeClass(int value) { some_value=value;};void show_data(void) { cout<<data<<"<<~some_value<<endl; };static void set_data(int value) {data=value; }private:static int data;int some_value};int SomeClass::datavoid main(void){SomeClass my_class(1001),your_class(2002);your_class. set_data(4004);my_elass. show_data()}
考题
请将下列程序的横线处补充完整,使得输出结果为bbaaincludeusing namespace std;class
请将下列程序的横线处补充完整,使得输出结果为bbaainclude<iostream>using namespace std;class A{public:______{cout<<"aa";}};class B:public A{public:~B(){cout<<"bb";}};int main(){B*p=new
考题
请阅读以下一段程序,并给出答案。class A{public:A(){ doSth() }virtual void doSth(){ printf("I am A");}}class B:public A{public:virtual void doSth(){ printf("I am B");}}B b;执行结果是什么?为什么?
考题
阅读以下说明和Java程序,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。
【说明】
以下Java代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分接口、类及其关系如图5-1所示。
【Java代码】
interface?DrawCircle?{? //绘制圆形 public(1) ;}class?RedCircle?implements?DrawCircle?{? ?//绘制红色圆形???????public?void?drawCircle(int?radius,intx,?int?y)??{????????????System.out.println("Drawing?Circle[red,radius:"?+?radius?+",x:"?+?x?+?",y:"?+y+?"]");???????}}class?GreenCircle?implements?DrawCircle?{????//绘制绿色圆形??????public?void?drawCircle(int?radius,?int?x,int?y)?{???????????System.out.println("Drawing?Circle[green,radius:"?+radius+",x:?"?+x+?",y:?"?+y+?"]");??????}}abstract?class?Shape?{????//形状? protected? ? (2)???;? ? public?Shape(DrawCircle?drawCircle)?{? ?this.drawCircle=?drawCircle;? ? ? public?abstract?void?draw();}class?Circle?extends?Shape?{? //圆形? ?private?int?x,y,radius;? public?Circle(int?x,int?y,intradius,DrawCircle?drawCircle)?{? ?(3)???;? this.x?=?x;? ? ? this.y?=?y;? ?this.radius?=radius;? }? ? ?public?void?draw()?{? ? drawCircle.? ?(4)? ?;? ? ? }}public?class?DrawCircleMain?{? public?static?void?main(String[]?args)?{? Shape?redCircle=new?Circle(?100,100,10,? (5) );//绘制红色圆形? Shape?greenCircle=new?Circle(200,200,10,(6) );//绘制绿色圆形? ?redCircle.draw(); greenCircle.draw();? ?}}
考题
阅读下列代码,选出该代码段正确的文件名()。 class A{ void method1(){ System.out.println("Method1 in class A"); } } public class B{ void method2(){ System.out.println("Method2 in class B"); } public static void main(String[] args){ System.out.println("main() in class B"); } }A.javaB.A.classC.B.javaD.B.class
考题
下列程序段执行结果是___________。 x = 1 print(type(x)) x = 1.0 print(type(x)) x = '1.0' print(type(x)A.<class 'int'> <class 'float'> <class 'str'>B.<class 'float'> <class 'int'> <class 'str'>C.<class 'str'> <class 'float'> <class 'int'>D.<class 'str'> <class 'int'> <class 'float'>
热门标签
最新试卷