单选题1. public class A {  2. public String doit(int x, int y) {  3. return “a”;  4. }  5.  6. public String doit(int... vals) {  7. return “b”;  8. } 9. }  Given:  25. A a=new A();  26. System.out.println(a.doit(4, 5));  What is the result?()A Line 26 prints “a” to System.out.B Line 26 prints „b” to System.out.C An exception is thrown at line 26 at runtime.D Compilation of class A will fail due to an error in line 6.

单选题
1. public class A {  2. public String doit(int x, int y) {  3. return “a”;  4. }  5.  6. public String doit(int... vals) {  7. return “b”;  8. } 9. }  Given:  25. A a=new A();  26. System.out.println(a.doit(4, 5));  What is the result?()
A

 Line 26 prints “a” to System.out.

B

 Line 26 prints „b” to System.out.

C

 An exception is thrown at line 26 at runtime.

D

 Compilation of class A will fail due to an error in line 6.


参考解析

解析: 暂无解析

相关考题:

执行下面程序段,屏幕上将输出( )。 public class Test { private int x=10,y=20; public Test (int x,int y) { System.out.println (x+this.x); System.out.println (y+y); } public static void main (String[] args) { Testt= new Test(30,50); } }A.无输出B.20 40C.40 100D.40 70

下列程序运行后的输出结果是( )。#include#includeusing namespace std;class Person{public:Person(string n):name(n) { coutprivate:int year,month,day;};class Student:public Person{public:Student(string n,int y,int m,int d,char c):birthday(y,m,d),sex(c),Person(n) { coutA. SB.PSC.DPSD.PDS

有如下类声明: class XA { int x; public: XA(int n){x=n;} }; class XB:public XA { int y; public: XB(int a,int b); }; 在构造函数XB的下列定义中,正确的是A.XB::XB(int a,int b):x(a),y(b){}B.XB::XB(int a,int b):XA(a),y(b){}C.XB::XB(int a,int b):x(a),XB(b){}D.XB::XB(int a,int b):XA(a),XB(b){}

执行下面程序,显示的结果为( )。 public class Test { public static void main (String args[]) { Test t=newTest(); System.out.println (Loverload ("2","3")); } int overload (intx,int y) {return x+y;} String overload (String x,Stnng y){return x+y;} }A.2B.3C.5D.23

下面程序段的输出结果为( )。 package test; public class ClassA { int x=20: static int y=6; public static void main(String args[]) { ClassB b=new ClassB; go(10); System.out.println("x="+b.x); } } class ClassB { int X; void go(int y) { ClassA a=new ClassA; x=a.Y ; } }A.x=10B.x=20C.x=6D.编译不通过

有如下程序: include class x { protected: int a; public:x(){ a=1;} }; class x 有如下程序: #include <iostream.h> class x { protected: int a; public: x() { a=1; } }; class x1 : virtual public x { public: x1() { a+=1; cout<<a; } }; class x2 : virtual public x { public: x2() { a+=2; cout<<a; } }; class y : public xl,public x2 { public: y() { cout<<a<<end1; } }; int main() { y obj; return O; } 该程序运行后的输出结果是( )。A.1B.123C.242D.244

下面程序段的输出结果为 package test; public class A { int x=20; static int y=6; public static void main(String args[]) { Class B b=new Class B(); b.go(10); System.out.println(”x=”+b.x); } } class Class B { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }A.x=10B.x=20C.x=6D.编译不通过

下面程序输出的结果是( )。 include using namespace std; class A{ 下面程序输出的结果是( )。 #include<iostream> using namespace std; class A{ int X; public: A(int x):x(++x){} ~A(){cout<<x;} }; class B:public A{ int y; public: B(int y):A(y),y(y){} ~B(){cout<<y;}; }; void main(){ B b(3); }A.34B.43C.33D.44

下列代码执行之后,输出的结果为______。 public class ex38 { public static void main(String[] args) { int x=12; int m=11; int y=13; int temp=x>y?x:y; temp=temp>m?temp:m; System.out.println (temp); } }A.1B.12C.13D.11

下列程序的输出结果是______。 include class base { int x,y; public: base(int i,i 下列程序的输出结果是______。include<iostream.h>class base{int x,y;public:base(int i,int j){x=i;y=j;}virtual int add( ){return x+y;}};class three:public base{int z;public:three(int i,int j,int k):base(i,j){z=k;)int add( ){return(base::add( )+z);}};void main( ){three*q=new three(10,20,30);cout<<q->add( )<<endl;}

给定java代码如下所示,在A处新增下列()方法,是对cal方法的重载。public class Test {  public void cal(int x, int y, int z) { } //A } A、public int cal(int x,int y,float z){return 0;}B、public int cal(int x,int y,int z){return 0;}C、public void cal(int x,int z){}D、public viod cal(int z,int y,int x){}

1. public class Target {  2. private int i = 0;  3. public int addOne() {  4. return ++i;  5. }  6. }  And:  1. public class Client {  2. public static void main(String[] args) {  3. System.out.println(new Target().addOne());  4. }  5. }  Which change can you make to Target without affecting Client?() A、 Line 4 of class Target can be changed to return i++;B、 Line 2 of class Target can be changed to private int i = 1;C、 Line 3 of class Target can be changed to private int addOne() {D、 Line 2 of class Target can be changed to private Integer i = 0;

1. public interface A {  2. public void doSomething(String thing);  3. }  1. public class AImpl implements A {  2. public void doSomething(String msg) { }  3. }  1. public class B {  2. public A doit() {  3. // more code here  4. }  5.  6. public String execute() { 7. // more code here  8. }  9. }  1. public class C extends B {  2. public AImpl doit() {  3. // more code here  4. }  5.  6. public Object execute() {  7. // more code here  8. }  9. }  Which statement is true about the classes and interfaces in the exhibit?() A、 Compilation will succeed for all classes and interfaces.B、 Compilation of class C will fail because of an error in line 2.C、 Compilation of class C will fail because of an error in line 6.D、 Compilation of class AImpl will fail because of an error in line 2.

1. public class A {  2. public void doit() {  3. }  4. public String doit() {  5. return “a”;  6. }  7. public double doit(int x) {  8. return 1.0;  9. }  10.}  What is the result?() A、 An exception is thrown at runtime.B、 Compilation fails because of an error in line 7.C、 Compilation fails because of an error in line 4.D、 Compilation succeeds and no runtime errors with class A occur.

class Top {  static int x = 1;  public Top(int y) { x *= 3; }  }  class Middle extends Top {  public Middle() { x += 1; }  public static void main(String [] args) {  Middle m = new Middle();  System.out.println(x);  }  }  结果为:() A、1B、2C、3D、编译失败

public class ConstOver {  public ConstOver (int x, int y, int z)  {  }  }   Which two overload the ConstOver constructor?()   A、 ConstOver ( ) { }B、 Protected int ConstOver ( ) { }C、 Private ConstOver (int z, int y, byte x) { }D、 Public Object ConstOver (int x, int y, int z) { }E、 Public void ConstOver (byte x, byte y, byte z) { }

Given:  1.  public class ConstOver {  2.  public constOver(int x, int y, int z) {  3.  }  4.  }   Which two overload the ConstOver Constructor?()A、 ConstOver() {}B、 protected int ConstOver(){}C、 private ConstOver(int z, int y, byte x ) {}D、 public Object ConstOver(Int x, int y, int z) {}E、 pubic void ConstOver (byte x, byte y, byte z) {}

public class MethodOver {   private int x, y;   private float z;   public void setVar(int a, int b, float c){   x = a;   y = b;   z = c;   }   }   Which two overload the setVar method?()A、 void setVar (int a, int b, float c){  x = a;  y = b;  z = c;  }B、 public void setVar(int a, float c, int b) {  setVar(a, b, c);  }C、 public void setVar(int a, float c, int b) {  this(a, b, c);  }D、 public void setVar(int a, float b){  x = a;  z = b;  }E、 public void setVar(int ax, int by, float cz) {  x = ax;  y = by;  z = cz;  }

1. public class A {  2. public String doit(int x, int y) {  3. return “a”;  4. }  5.  6. public String doit(int... vals) {  7. return “b”;  8. } 9. }  Given:  25. A a=new A();  26. System.out.println(a.doit(4, 5));  What is the result?() A、 Line 26 prints “a” to System.out.B、 Line 26 prints „b” to System.out.C、 An exception is thrown at line 26 at runtime.D、 Compilation of class A will fail due to an error in line 6.

public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()A、 public class Circle implements Shape { private int radius; }B、 public abstract class Circle extends Shape { private int radius; }C、 public class Circle extends Shape { private int radius; public void draw(); }D、 public abstract class Circle implements Shape { private int radius; public void draw(); }E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

单选题1. public class A {  2. public String doit(int x, int y) {  3. return “a”;  4. }  5.  6. public String doit(int... vals) {  7. return “b”;  8. } 9. }  Given:  25. A a=new A();  26. System.out.println(a.doit(4, 5));  What is the result?()A Line 26 prints “a” to System.out.B Line 26 prints „b” to System.out.C An exception is thrown at line 26 at runtime.D Compilation of class A will fail due to an error in line 6.

单选题1. public class A {  2. public void doit() {  3. }  4. public String doit() {  5. return “a”;  6. }  7. public double doit(int x) {  8. return 1.0;  9. }  10.}  What is the result?()A An exception is thrown at runtime.B Compilation fails because of an error in line 7.C Compilation fails because of an error in line 4.D Compilation succeeds and no runtime errors with class A occur.

多选题public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()Apublic class Circle implements Shape { private int radius; }Bpublic abstract class Circle extends Shape { private int radius; }Cpublic class Circle extends Shape { private int radius; public void draw(); }Dpublic abstract class Circle implements Shape { private int radius; public void draw(); }Epublic class Circle extends Shape { private int radius;public void draw() {/* code here */} }Fpublic abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

单选题public class Parent{     public void change(int x){} }  public class Child extends Parent{     //覆盖父类change方法  }  下列哪个声明是正确的覆盖了父类的change方法?()A protected void change(int x){}B public void change(int x, int y){}C public void change(String s){}D public void change(int x){}

多选题public class ConstOver {  public ConstOver (int x, int y, int z)  {  }  }   Which two overload the ConstOver constructor?()AConstOver ( ) { }BProtected int ConstOver ( ) { }CPrivate ConstOver (int z, int y, byte x) { }DPublic Object ConstOver (int x, int y, int z) { }EPublic void ConstOver (byte x, byte y, byte z) { }

多选题Given:  1.  public class ConstOver {  2.  public constOver(int x, int y, int z) {  3.  }  4.  }   Which two overload the ConstOver Constructor?()AConstOver() {}Bprotected int ConstOver(){}Cprivate ConstOver(int z, int y, byte x ) {}Dpublic Object ConstOver(Int x, int y, int z) {}Epubic void ConstOver (byte x, byte y, byte z) {}

单选题现有      public class Parentt      public void change (int x){)     )      public class Child extends Parent{     //覆盖父类change方法     }      下列哪个声明是正确的覆盖了父类的change方法?()A  protected void change (int x){}B  public void change(int x,  int y){}C  public void change (int x){}D  public void change (String s){}

单选题1. class Over{   2. int doIt(long x) { return 3;}   3. }   4.   5. class Under extends Over{   6. //insert code here 7. }   和四个方法:   short doIt(int y) {return 4;}   int doIt(long x,long y){return 4;}   private int doIt(Short y){ return 4;}   protected int doIt(long x){return 4;}   分别插入到第6行,有几个可以通过编译?()A2B3C4D0E1