多选题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


相似考题
更多“多选题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”相关问题
  • 第1题:

    下列程序的输出结果是 #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的条件。

  • 第2题:

    下列程序的输出结果为【 】。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)++的作用是将较大值再进行增一运算。

  • 第3题:

    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

  • 第4题:

    11. public class Counter {  12. public static void main(String[] args) {  13. int numArgs = /* insert code here */;  14. }  15. }  and the command line: java Counter one fred 42 Which code, inserted at line 13, captures the number of arguments passed into the program?() 

    • A、 args.count
    • B、 args.length
    • C、 args.count()
    • D、 args.length()
    • E、 args.getLength()

    正确答案:B

  • 第5题:

    public class X {  public X aMethod() { return this;}  }  public class Y extends X {  }  Which two methods can be added to the definition of class Y?()

    • A、 public void aMethod() {}
    • B、 private void aMethod() {}
    • C、 public void aMethod(String s) {}
    • D、 private Y aMethod() { return null; }
    • E、 public X aMethod() { return new Y(); }

    正确答案:C,E

  • 第6题:

    11. public class Test {  12. public void foo() {  13. assert false;  14. assert false;  15. }  16. public void bar(){  17. while(true){  18. assert false;  19. }  20. assert false;  21. }  22. }  What causes compilation to fail?()  

    • A、 Line 13
    • B、 Line 14
    • C、 Line 18
    • D、 Line 20

    正确答案:D

  • 第7题:

    interface A { public int getValue() }  class B implements A {  public int getValue() { return 1; }  }  class C extends B {  // insert code here  }  Which three code fragments, inserted individually at line 15, make use of polymorphism?()

    • A、 public void add(C c) { c.getValue(); }
    • B、 public void add(B b) { b.getValue(); }
    • C、 public void add(A a) { a.getValue(); }
    • D、 public void add(A a, B b) { a.getValue(); }
    • E、 public void add(C c1, C c2) { c1.getValue(); }

    正确答案:B,C,D

  • 第8题:

    10. class Inner {  11. private int x;  12. public void setX( int x) { this.x = x; }  13. public int getX() { return x; }  14. }  15.  16. class Outer {  17. private Inner y;  18. public void setY( Inner y) { this.y = y; }  19. public Inner getY() { return y; }  20. }  21.  22. public class Gamma {  23. public static void main( String[] args) { 24. Outer o = new Outer(); 25. Inner i = new Inner();  26.int n=10;  27. i.setX(n);  28. o.setY(i);  29. // insert code here  30. System.out.println( o.getY().getX());  31. }  32. }  Which three code fragments, added individually at line 29, produce the output 100?()

    • A、 n = 100;
    • B、 i.setX( 100);
    • C、 o.getY().setX( 100);
    • D、 i = new Inner(); i.setX( 100);
    • E、 o.setY( i); i = new Inner(); i.setX( 100);
    • F、 i = new Inner(); i.setX( 100); o.setY( i);

    正确答案:B,C,F

  • 第9题:

    Given:   10. class One {   11. void foo() { }   12. }   13. class Two extends One {   14. //insert method here   15. }   Which three methods, inserted individually at line 14, will correctly complete class Two?()

    • A、 public void foo() { /* more code here */ }
    • B、 private void foo() { /* more code here */ }
    • C、 protected void foo() { /* more code here */ }
    • D、 int foo() { /* more code here */ }  
    • E、 void foo() { /* more code here */ }

    正确答案:A,C,E

  • 第10题:

    单选题
    11. public class Counter {  12. public static void main(String[] args) {  13. int numArgs = /* insert code here */;  14. }  15. }  and the command line: java Counter one fred 42 Which code, inserted at line 13, captures the number of arguments passed into the program?()
    A

     args.count

    B

     args.length

    C

     args.count()

    D

     args.length()

    E

     args.getLength()


    正确答案: C
    解析: 暂无解析

  • 第11题:

    单选题
    10. class Line {  11. public class Point { public int x,y; }  12. public Point getPoint() { return new Point(); }  13. }  14. class Triangle {  15. public Triangle() {  16. // insert code here  17. }  18. }  Which code, inserted at line 16, correctly retrieves a local instance of a Point object?()
    A

     Point p = Line.getPoint();

    B

     Line.Point p = Line.getPoint();

    C

     Point p = (new Line()).getPoint();

    D

     Line.Point p = (new Line()).getPoint();


    正确答案: A
    解析: 暂无解析

  • 第12题:

    多选题
    10. abstract public class Employee {  11. protected abstract double getSalesAmount();  12. public double getCommision() {  13. return getSalesAmount() * 0.15;  14. }  15. }  16. class Sales extends Employee {  17. // insert method here  18. }  Which two methods, inserted independently at line 17, correctly complete the Sales class?()
    A

    double getSalesAmount() { return 1230.45; }

    B

    public double getSalesAmount() { return 1230.45; }

    C

    private double getSalesAmount() { return 1230.45; }

    D

    protected double getSalesAmount() { return 1230.45; }


    正确答案: B,C
    解析: 暂无解析

  • 第13题:

    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。

  • 第14题:

    有以下程序: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的赋值。

  • 第15题:

    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

  • 第16题:

    10. abstract public class Employee {  11. protected abstract double getSalesAmount();  12. public double getCommision() {  13. return getSalesAmount() * 0.15;  14. }  15. }  16. class Sales extends Employee {  17. // insert method here  18. }  Which two methods, inserted independently at line 17, correctly complete the Sales class?()

    • A、 double getSalesAmount() { return 1230.45; }
    • B、 public double getSalesAmount() { return 1230.45; }
    • C、 private double getSalesAmount() { return 1230.45; }
    • D、 protected double getSalesAmount() { return 1230.45; }

    正确答案:B,D

  • 第17题:

    public class Score implements Comparable {  private int wins, losses;  public Score(int w, int 1) { wins = w; losses = 1; }  public int getWins() { return wins; }  public int getLosses() { return losses; }  public String toString() {  return “<“ + wins + “,“ + losses + “>”; }  // insert code here  }  Which method will complete this class?() 

    • A、 public int compareTo(Object o) {/*mode code here*/}
    • B、 public int compareTo(Score other) {/*more code here*/}
    • C、 public int compare(Score s1,Score s2){/*more code here*/}
    • D、 public int compare(Object o1,Object o2){/*more code here*/}

    正确答案:B

  • 第18题:

    11. class Payload {  12. private int weight;  13. public Payload(int wt) { weight = wt; }  13. public void setWeight(mt w) { weight = w; }  15. public String toString { return Integer.toString(weight); }  16. }  17.  18. public class TestPayload {  19. static void changePayload(Payload p) { 20. /* insert code here */ 21. }  22.  23. public static void main(String[] args) {  24. Payload p = new Payload();  25. p.setWeight(1024);  26. changePayload(p);  27. System.out.println(”The value of p is “+ p);  28. }  29. }  Which statement, placed at line 20, causes the code to print “The value of p is 420.”?() 

    • A、 p.setWeight(420);
    • B、 p.changePayload(420);
    • C、 p = new Payload(420);
    • D、 Payload.setWeight(420);
    • E、 p = Payload.setWeight(420);
    • F、 p = new Payload(); p.setWeight(420);

    正确答案:A

  • 第19题:

    10. public class Foo implements java.io.Serializable {  11. private int x;  12. public int getX() { return x; }  12.publicFoo(int x){this.x=x; }  13. private void writeObject( ObjectOutputStream s)  14. throws IOException {  15. // insert code here  16. }  17. }  Which code fragment, inserted at line 15, will allow Foo objects to be correctly serialized and deserialized?() 

    • A、 s.writeInt(x);
    • B、 s.serialize(x);
    • C、 s.writeObject(x);
    • D、 s.defaultWriteObject();

    正确答案:D

  • 第20题:

    10. class Line {  11. public class Point { public int x,y; }  12. public Point getPoint() { return new Point(); }  13. }  14. class Triangle {  15. public Triangle() {  16. // insert code here  17. }  18. }  Which code, inserted at line 16, correctly retrieves a local instance of a Point object?() 

    • A、 Point p = Line.getPoint();
    • B、 Line.Point p = Line.getPoint();
    • C、 Point p = (new Line()).getPoint();
    • D、 Line.Point p = (new Line()).getPoint();

    正确答案:D

  • 第21题:

    多选题
    10. class Inner {  11. private int x;  12. public void setX( int x) { this.x = x; }  13. public int getX() { return x; }  14. }  15.  16. class Outer {  17. private Inner y;  18. public void setY( Inner y) { this.y = y; }  19. public Inner getY() { return y; }  20. }  21.  22. public class Gamma {  23. public static void main( String[] args) { 24. Outer o = new Outer(); 25. Inner i = new Inner();  26.int n=10;  27. i.setX(n);  28. o.setY(i);  29. // insert code here  30. System.out.println( o.getY().getX());  31. }  32. }  Which three code fragments, added individually at line 29, produce the output 100?()
    A

    n = 100;

    B

    i.setX( 100);

    C

    o.getY().setX( 100);

    D

    i = new Inner(); i.setX( 100);

    E

    o.setY( i); i = new Inner(); i.setX( 100);

    F

    i = new Inner(); i.setX( 100); o.setY( i);


    正确答案: E,C
    解析: 暂无解析

  • 第22题:

    多选题
    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


    正确答案: B,A
    解析: 暂无解析

  • 第23题:

    单选题
    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.


    正确答案: D
    解析: 暂无解析

  • 第24题:

    单选题
    11. class Payload {  12. private int weight;  13. public Payload(int wt) { weight = wt; }  13. public void setWeight(mt w) { weight = w; }  15. public String toString { return Integer.toString(weight); }  16. }  17.  18. public class TestPayload {  19. static void changePayload(Payload p) { 20. /* insert code here */ 21. }  22.  23. public static void main(String[] args) {  24. Payload p = new Payload();  25. p.setWeight(1024);  26. changePayload(p);  27. System.out.println(”The value of p is “+ p);  28. }  29. }  Which statement, placed at line 20, causes the code to print “The value of p is 420.”?()
    A

     p.setWeight(420);

    B

     p.changePayload(420);

    C

     p = new Payload(420);

    D

     Payload.setWeight(420);

    E

     p = Payload.setWeight(420);

    F

     p = new Payload(); p.setWeight(420);


    正确答案: A
    解析: 暂无解析