多选题Given:   11. // insert code here   12. private N min, max;   13. public N getMin() { return min; }   14. public N getMax() { return max; }   15. public void add(N added) {   16. if (min == null || added.doubleValue()  max.doubleValue())  19. max = adde

题目
多选题
Given:   11. // insert code here   12. private N min, max;   13. public N getMin() { return min; }   14. public N getMax() { return max; }   15. public void add(N added) {   16. if (min == null || added.doubleValue()  max.doubleValue())  19. max = added;   20. }   21. }   Which two, inserted at line 11, will allow the code to compile?()
A

A

B

B

C

C

D

D

E

E

F

F

参考答案和解析
正确答案: C,B
解析: 暂无解析
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Given:11.//insertcodehere12.&e

Given:

11.//insertcodehere

12.privateNmin,max;

13.publicNgetMin(){returnmin;}

14.publicNgetMax(){returnmax;}

15.publicvoidadd(Nadded){

16.if(min==null||added.doubleValue()<min.doubleValue())

17.min=added;

18.if(max==null||added.doubleValue()>max.doubleValue())

19.max=added;

20.}

21.}

Whichtwo,insertedatline11,willallowthecodetocompile?()


参考答案:B, D

第2题:

下列程序的输出结果是 #include"iostream" using namespace std; int Max(int a,int b) { if(a>b) return a; else return b; } void main( ) { int m,n; m=10,n=5; int max = Max(m,n); cout<<max<<endl; }

A.10

B.程序有误

C.1

D.0


正确答案:A
解析:本题函数Max的功能是求出两个整数中的较大者,并且通return语句返回。注意:return语句的用法,注意return的条件。

第3题:

●试题二

阅读下列程序或函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。

【函数2.1说明】

函数strcmp()是比较两个字符串s和t的大小。若s<t函数返回负数;若s=t函数返回0;若s>t,函数返回正数。

【函数2.1】

int strcmp(char *s,char *t)

{ while(*s && *t && (1) ){

s++;t++;

}

return (2) ;

}

【程序2.2说明】

在n行n列的矩阵中,每行都有最大的数,本程序求这n个最大数中的最小一个。

【程序2.2】

#includestdio.h

#define N 100

int a[N][N];

void main()

{ int row ,col,max,min,n;

/*输入合法n(<100),和输入n×n个整数到数组a的代码略*/

for (row=0;row<n;row++){

for(max=a[row][0],col=1;col<n;col++)

if( (3) )max=a[row][col];

if( (4) )min=max;

else if( (5) )min=max;

}

printf ("The min of max numbers is %d\n",min);

}


正确答案:

●试题二

【答案】(1)*s == *t(2) *s - *t

【解析】*s *t相等才执行循环体。返回二者差值,恰好符合题目要求。

【答案】(3) arow][col>max (4) row == 0(5) max<min

【解析】当前值比max大,则把它赋给maxmax是本行最大值。初始化min为第一行的max。该行的maxmin小,则将max赋给min

 

第4题:

11. public void testIfA() {  12. if(testIfB(”True”)) {  13. System.out.println(”True”);  14. } else {  15. System.out.println(”Not true”);  16. }  17. }  18. public Boolean testIfB(String str) {  19. return Boolean.valueOf(str);  20. }  What is the result when method testIfA is invoked?() 

  • A、 True
  • B、 Not true
  • C、 An exception is thrown at runtime.
  • D、 Compilation fails because of an error at line 12.
  • E、 Compilation fails because of an error at line 19.

正确答案:A

第5题:

下列程序的输出结果为【 】。ineludeint &max(int &x, int &y){return (x

下列程序的输出结果为【 】。

inelude<iostream. h>

int &max(int &x, int &y)

{return (x>y? x: y); }

void main() {

int n=3, m=12;

max(m, n)++

cout<<"m="<<m<<", n= "<<n<<end1;

}


正确答案:m=13n=3
m=13,n=3 解析:本题考察引用作为形参进行参数传递的知识。max函数的功能是返回较大的那个数,而max(m,n)++的作用是将较大值再进行增一运算。

第6题:

在程序中,给出两个整数4和5,计算他们的和,并在屏幕上显示出来。请将程序补充完整。

注意:请勿修改main()主方法和其他已有语句内容,仅在横线处填入适当语句。

______Add

{

private int a;

private int b;

public Add(int n1,int n2)

{

a=nl;

b=n2;

}

public int getAdd()

{

return a +b;

}

}

public class basic

{

public ______void main(String[] args)

{

int n1=4, n2=5;

Add aAddB=______Add(nl,n2);

System.out.println("4+5="+aAddB.getAdd());

}

}


正确答案:class new static
class new static 解析:本题考查知识点:面向对象编程的基本概念和特征,类的基本组成和使用,对象的生成和使用。解题思路:本题主要考查Java编程中类的使用。主方法生成Add类对象的实例aAddB,然后调用getAdd()方法计算出4加5的和。首先,定义类必须使用关键字class,因此第1个空应该填写class。在生成类的对象时,必须使用关键字new,由此得到第2个空。 Main方法作为Java的一个特殊方法,其最大的特点就是这个方法始终都是静态的,因为一个程序必须要有一个静态的入口,系统才能对其进行调用,所以第3个空应该填写static。

第7题:

fun函数的功能是首先对a所指的N行N列的矩阵找出各行中最大的数,再求这N个最大值中最小的那个数作为函数值返回,请填空。#include <stdio.h>#define N 100int fun(int(*a)[N]){ int row,col,max,min; for(row=0;row<N;row++) { for(max=a[row][0],col=1;col<N;col++) if() max=a[row][col]; if(row==0) min=max; else if() min=max; } return min;}


正确答案:max<a[row][col],max<min
本题中的第一空要求判断出每一行中的最大数,应该填写条件max<a[row] [col],第二空要求从N个最大值中找出最小的数,应填入条件max<min。

第8题:

阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。

[说明]

编写一个字符界面的Java Application 程序,接受用户输入的10个整数,并输出这10个整数的最大值和最小值。

[Java 代码]

import java. io.* ;

public class abc

{

public static void main ((1))

{int i, n=10, max=0, min=0, temp=0;

try {

BufferedReader br = new BufferedReader (

new InputStreamReader ( System.in ) );

max = min =Integer. parselnt ( br. readLine ( ) );

}. (2) ( IOExccption e ) {} ;

for ( i=2 ; i<=n ; i++ ) {

try {

BufferedReader br = new (3) (

new InputStreamReader ( System. in ) );

temp =(4) ( br. readLine ( ));

if (temp>max ) max=temp;

if (temp<min) (5)

} catch (IOException e ) {};

}

System.out.println ( "max="+max+"\nmin="+min );

}

}


正确答案:(1)String args [] (2) Catch (3) BufferedReadsr (4) Integer. parseInt (5) min=temp;
(1)String args [] (2) Catch (3) BufferedReadsr (4) Integer. parseInt (5) min=temp;

第9题:

有以下程序:includeusing namespace std;Class sample{private:int n;public:sample(

有以下程序: #include<iostream> using namespace std; Class sample { private: int n; public: sample(){} sample(int m) { n=m; } sample add(sample s1,samplc s2) { this-->n=s1.n+s2.n; return(*this); } void disp(

A.n=10

B.n=5

C.n=20

D.n=15


正确答案:D
解析: 本题考查this指针的使用类成员函数add中通过this指针实现私有数据成员n的赋值。

第10题:

10. interface Foo { int bar(); }  11. public class Sprite {  12. public int fubar( Foo foo) { return foo.bar(); }  13. public void testFoo() {  14. fubar(  15. // insert code here  16.);  17. }  18. }  Which code, inserted at line 15, allows the class Sprite to compile?() 

  • A、 Foo { public int bar() { return 1; } }
  • B、 new Foo { public int bar() { return 1; } }
  • C、 newFoo() { public int bar(){return 1; } }
  • D、 new class Foo { public int bar() { return 1; } }

正确答案:C

更多相关问题