类A及其派生类B定义如下:class A{ public int getInfo(int a) { return a; }}public class B extends A{ public float getInfo(int b) { return b; } public static void main(String[]args) { A a=new A(); B b=new B(); System.out.println(a.getInfo(3)+","+b.getInfo(5)); }}关于上述程序代码的叙述中正确的是 ( )A.第10行不能通过编译B.程序通过编译,输出结果为:3,3C.程序通过编译,输出结果为3,5D.程序通过编译,输出结果为:5,5

类A及其派生类B定义如下:class A{ public int getInfo(int a) { return a; }}public class B extends A{ public float getInfo(int b) { return b; } public static void main(String[]args) { A a=new A(); B b=new B(); System.out.println(a.getInfo(3)+","+b.getInfo(5)); }}关于上述程序代码的叙述中正确的是 ( )

A.第10行不能通过编译

B.程序通过编译,输出结果为:3,3

C.程序通过编译,输出结果为3,5

D.程序通过编译,输出结果为:5,5


相关考题:

若类A和类B的定义如下:includeclass A{int i,j;public:int geti(){return i;}};class 若类A和类B的定义如下: #include<malloc.h> class A { int i,j; public: int geti() { return i; } }; class B:public A { int k; public: void make() { k=i*j; } }; 则上述定义中非法的表达式是( )。A.k=i*jB.int k;C.return i;D.void make();

下列选项中的 方法可以正确地加入类Child中,且父类的方法不会被覆盖。 public class Parent{ public int addValue(int a,int b){ int s; s=a+b; return s; } } class Child extends Parent{ }A.int addValue(int a,int b){∥do something…}B.public void addValue( ){∥do something…}C.public int addValue(int a,int b)throws MyException{∥do something…}D.public float addValue(int a,int b,float b=1.0){∥do something…}

若类A和类B的定义如下class A{int i,j;public:int geti( ){return i;}};class B:public A{int k:public:void make( ){k=i*j;}};则上述定义中非法的语句是A.k=i*jB.int k;C.return i;D.void make()

有如下程序段: public class Parent { public int addValue (int a,intB){ int s; s=a+b; return 3; } } class Child extends Parent {} 则下列选项中,可以正确加入类Child中且父类的方法不会被覆盖的是( )。A.int addValue (int a,intB){//do something...}B.public void addValue() {//do something...}C.public int addValue (int a,intB)throws MyException {//do something...}D.public float addValue (int a,int b,float b=1.0) {//do someting...}

已知如下类定义: class Base { public Base (){ //... } public Base ( int m ){ //... } protected void fun( int n ){ //... } } public class Child extends Base{ // member methods } 如下哪句可以正确地加入子类中?() A.private void fun( int n ){ //...}B.void fun ( int n ){ //... }C.protected void fun ( int n ) { //... }D.public void fun ( int n ) { //... }

在如下源代码文件Test.java中, 哪个是正确的类定义?() A.public class test { public int x = 0; public test(int x) { this.x = x; } }B.public class Test{ public int x=0; public Test(int x) { this.x = x; } }C.public class Test extends T1, T2 { public int x = 0; public Test (int x) { this.x = x; } }D.public class

有如下类定义:class Point{public:Point(int xx=0,int yy=0):x(xx),y(yy) { }private:int x,y;};class Circle:public Point{public:Circle(int r):radius(r) { }private:int radius;};派生类Circle中数据成员的个数是( )。A、3B、1C、5D、2

若类A和类B的定义如下: class A { int i,j; public: int geti () { return i; } }; class B : public A { int k; public: void make () { k=i*j; } }; 则上述定义中非法的语句是A.k=i*j;B.int k;C.return i;D.void make()

若类A和类B的定义如下:includeclass A{int i*j;public:int geti(){return i;}};class 若类A和类B的定义如下: #include<malloc.h> class A { int i*j; public: int geti() { return i; } }; class B: public A { int k; public: void make() { k=i*j; } ); 则上述定义中非法的表达式是( )。A.k=i*j;B.int k;C.return i;D.void make();

若类A和类B的定义如下: class A [ int i,j; public: int geti() { return i; } }; class B:public A { int k; public: void make() { k=i*j; } }; 则上述定义中非法的表达式是A.k=i*jB.int k;C.retum i;D.void make()

在下列源代码文件Test.java中,正确定义类的代码是( )。A.pblic class test { public int x=0; public test(int x) { this. x=x;} }B.public class Test { public int x=0; public Test(int x) { this. x=x;} }C.public class Test extends T1,T2{ public int x = 0; public Test(int x){ this. x = x; } }D.protected class Test extends T2{ public int x = 0; public Test(int x) { this. x = x; } }

若类A和类B的定义如下: class A { int i,j; public: int geti() { return i; } }; class B: public A { int k; public: void make() { k=i*j } }; 则上述定义中A.k=i*j;B.int k;C.return i;D.void make()

若类A和类B的定义如下: class A { int i,j; public: int geti() { return i; } }; class B : public A { int k; public: void make() { k=i*j; } }; 则上述定义中非法的表达式是( )。A.k=i*jB.int k;C.return i;D.void make()

在下列源代码文件Test.java中, ( )是正确的类定义。A.public class test{B.public class Test{ public int x=0;public int x=0; public test (intx) public Test (int x){ {this.x=x; this.x=x;} }} }C.public class Test extends T1,T2{D.protected class Test extends T2{ public int=0;public int x=0; public Test(int x){Public Test (int x){ this.x=x;this.x=x: }} }}

在下列源代码文件Test.java中,哪个选项是正确的类定义? ( )A.public class test { public int x=0; public test(int x) { this.x=x; } }B.public class Test { public int x=0; public Test(int x) { this.x=x; } }C.public class Test extends Ti,T2 { public int x=0; public Test(int x) { this.x=x; } }D.protected class Test extends T2 { public int x=0; public Test(int x) { this.x=x; } }

class A {  protected int method1(int a, int b) { return 0; }  }  Which two are valid in a class that extends class A?() A、 public int method1(int a, int b) { return 0; }B、 private int method1(int a, int b) { return 0; }C、 private int method1(int a, long b) { return 0; }D、 public short method1(int a, int b) { return 0: }E、 static protected int method1(int a, int b) { return 0; }

Which statements concerning the following code are true?()   class a {   public a() {}   public a(int i) { this(); }   }   class b extends a {   public boolean b(String msg) { return false; }   }   class c extends b  {  private c() { super(); }   public c(String msg) { this(); }   public c(int i) {}   }  A、The code will fail to compile.B、The constructor in a that takes an int as an argument will never be called as a result of constructing an  object of class b or c.C、Class c has three constructors.D、Objects of class b cannot be constructed.E、At most one of the constructors of each class is called as a result of constructing an object of class c.

类Test1定义如下: 1.public class Test1{ 2. public float aMethod(float a,float b){ return 0;} 3. 4.} 将以下哪种方法插入行3是不合法的。()A、public float aMethod(float a, float b,float c){ return 0;}B、public float aMethod(float c,float d){ return 0;}C、public int aMethod(int a, int b){ return 0;}D、private float aMethod(int a,int b,int c){ return 0;}

class One {   public One foo() { return this; }  }  class Two extends One {  public One foo() { return this; }  }  class Three extends Two {   // insert method here  }  Which two methods, inserted individually, correctly complete the Three class?()A、 public void foo() { }B、 public int foo() { return 3; }C、 public Two foo() { return this; }D、 public One foo() { return this; }E、 public Object foo() { return this; }

What produces a compiler error?()  A、 class A { public A(int x) {} }B、 class A {} class B extends A { B() {} }C、 class A { A() {} } class B { public B() {} }D、 class Z { public Z(int) {} } class A extends Z {}

public class Parent {  public int addValue( int a, int b) {     int s;     s = a+b;     return s;     }     }  class Child extends Parent {  }  Which methods can be added into class Child?()   A、 int addValue( int a, int b ){// do something...}B、 public void addValue (){// do something...}C、 public int addValue( int a ){// do something...}D、 public int addValue( int a, int b )throws MyException {//do something...}

public class Parent {     int change() {…}     }  class Child extends Parent {     }  Which methods can be added into class Child?()    A、 public int change(){}B、 int chang(int i){}C、 private int change(){}D、 abstract int chang(){}

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 */ } }

多选题Which statements concerning the following code are true?()   class a {   public a() {}   public a(int i) { this(); }   }   class b extends a {   public boolean b(String msg) { return false; }   }   class c extends b  {  private c() { super(); }   public c(String msg) { this(); }   public c(int i) {}   }AThe code will fail to compile.BThe constructor in a that takes an int as an argument will never be called as a result of constructing an  object of class b or c.CClass c has three constructors.DObjects of class b cannot be constructed.EAt most one of the constructors of each class is called as a result of constructing an object of class c.

多选题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 */ } }

单选题What produces a compiler error?()A class A { public A(int x) {} }B class A {} class B extends A { B() {} }C class A { A() {} } class B { public B() {} }D class Z { public Z(int) {} } class A extends Z {}

多选题class One {   public One foo() { return this; }  }  class Two extends One {  public One foo() { return this; }  }  class Three extends Two {   // insert method here  }  Which two methods, inserted individually, correctly complete the Three class?()Apublic void foo() { }Bpublic int foo() { return 3; }Cpublic Two foo() { return this; }Dpublic One foo() { return this; }Epublic Object foo() { return this; }