网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
class super {   public float getNum() {return 3.0f;}   }   public class Sub extends Super {   }   Which method, placed at line 6, will cause a compiler error?()
A

 Public float getNum() {return 4.0f; }

B

 Public void getNum (){}

C

 Public void getNum (double d){}

D

 Public double getNum (float d) {retrun 4.0f; }


参考答案

参考解析
解析: 暂无解析
更多 “单选题class super {   public float getNum() {return 3.0f;}   }   public class Sub extends Super {   }   Which method, placed at line 6, will cause a compiler error?()A  Public float getNum() {return 4.0f; }B  Public void getNum (){}C  Public void getNum (double d){}D  Public double getNum (float d) {retrun 4.0f; }” 相关考题
考题 有如下程序: include using namespace std; class Test { public 有如下程序: #include<iostream> using namespace std; class Test { public: Test(){n+=2;} ~Test(){n-=3;} static int getNum(){return n;} private: static int n; }; int Tesl::n=1 int main() { Test*p=new Test; delete p; cout<<"n="<<Tes::tgetNum()<<endl; return 0; } 执行后的输出结果是A.n=0B.n=1C.n=2D.n=3

考题 有如下程序: include using namespace std; class Test{ public: Tes 有如下程序: #include<iostream> using namespace std; class Test{ public: Test() {n+=2;} ~Test() {n-=3;} static int getNum(){return n;} private: static int n; }; int Test::n=1; int main() { Test*p=new Test; delete p; cout<<"n="<<Test::getNum()<<endl; return 0; } 执行后的输出结果是( )。A.n=0B.n=1C.n=2D.n=3

考题 有以下程序: float f1(float n) { return n*n; } float f2(float n) { return 2*n; } main() {float(*p1)(float),(*p2)(float),(*t)(float),y1,y2; p1:f1; p2=f2; y1=p2(p1(2.0)); t=p1; p1=p2; p2=t; y2=p2(p1(2.0)); printf("%3.0f,%3.0f\n",y1,y2); } 程序运行后的输出结果是 ______。A.8, 16B.8, 8C.16, 16D.4, 8

考题 下列程序的执行结果是______。 include class Student { public: Student(int xx){x= 下列程序的执行结果是______。include<iostream.h>class Student{public:Student(int xx){x=xx;}virtual float calcTuition( );protected:int x;};float Studertt::calcTuition( ){return float(x*x);}class GraduateStudent:public Student{public:GraduateStudent(int xx):Student(xx){}float calcTuition( );};float Graduatestudent::calcTuition( ){return float(x*2);}void main( ){Student s(20);GraduateStudent gs(30);cout<<s.calcTuition( )<<" "<<gs.calcTuition( )<<endl;//计算学生s和研究生gs的学费}

考题 有如下程序:include usingnamespacestd:class Test{public: Test(){n+=2; ~Test(){n- 有如下程序:#include <iostream>using namespace std:class Test{public: Test() {n+=2; ~Test() {n-=3; ; static int getNum() {return n;}privaue: static int n:};int Test::n=1;int main(){ Test* p=new Test; delete p; cout<<"n="<<Test::getNum()<<end1; return 0;} 执行后的输出结果是A.n=0B.n=1C.n=2D.n=3

考题 有如下程序: include using namespace std;class Test {public: Test() {n+=2;} ~Tes 有如下程序: #include <iostream> using namespace std; class Test { public: Test() {n+=2;} ~Test() {n-=3;} static int getNum(){retum n;} private: static int n; }; int Test:: n=1; int main() { Test*p=new Test; delete p; cout<<"n="<<Test:: getNum()<<end1; return 0; };执行后的输出结果是______.A.n=0B.n=1C.n=2D.n=3

考题 有以下程序:includeincludeusingnamespacestd;classDistance;classpoint{pub 有以下程序: #include <iostream> #include <cmath> using namespace std; class Distance; class point { public: friend class Distance; Point(int a,int B) { x=a; Y=b; } void Print() { cout<<"X= "<<X<<end1; cout<<"Y= "<<Y<<end1; } private: float X,Y; }; class Distance { public: float Dis(Point p,Point q); }; float Distance :: Dis(Point p,Point q) { float result; result=sqrt((p.X-q.X)*(p.X-q.X)+(p.Y-q.Y)*(p.Y-q.Y)); cout<<result<<end1; retUrn result; } int main() { Point p(10,10),q(10,30); Distance d; d.Dis(p,q); return 0; } 运行后的输出结果是( )。A.10B.30C.0D.20

考题 public class Person {  private String name, comment;  private int age;  public Person(String n, int a, String c) {  name = n; age = a; comment = c;  }  public boolean equals(Object o) {  if(! (o instanceof Person)) return false;  Person p = (Person)o;  return age == p.age  name.equals(p.name);  }  }  What is the appropriate definition of the hashCode method in class Person?() A、 return super.hashCode();B、 return name.hashCode() + age * 7;C、 return name.hashCode() + comment.hashCode() /2;D、 return name.hashCode() + comment.hashCode() / 2 - age * 3;

考题 1. class BaseClass {  2. private float x = 1.of;  3. protected float getVar() { return x; }  4. }  5. class SubClass extends BaseClass {  6. private float x = 2.Of;  7. // insert code here 8. }   Which two are valid examples of method overriding when inserted at line 7?() A、 float getVar() { return x; }B、 public float getVar() { return x; }C、 public double getVar() { return x; }D、 protected float getVar() { return x; }E、 public float getVar(float f) { return f; }

考题 class super {   public float getNum() {return 3.0f;}   }   public class Sub extends Super {   }   Which method, placed at line 6, will cause a compiler error?()A、 Public float getNum() {return 4.0f; }B、 Public void getNum (){}C、 Public void getNum (double d){}D、 Public double getNum (float d) {retrun 4.0f; }

考题 class super {  public int getLength()  {return 4;}  }  public class Sub extends Super {  public long getLength() {return 5;}  public static void main (String[]args)  {  super sooper = new Super ();  Sub sub = new Sub();  System.out.printIn(  sooper.getLength()+ “,” + sub.getLength()   };  }  What is the output?()  A、 4, 4B、 4, 5C、 5, 4D、 5, 5E、 The code will not compile.

考题 public class MethodOver {   public void setVar (int a, int b, float c) {   }   }   Which two overload the setVar method?()A、 Private void setVar (int a, float c, int b) {}B、 Protected void setVar (int a, int b, float c) {}C、 Public int setVar (int a, float c, int b) (return a;)D、 Public int setVar (int a, int b, float c) (return a;)E、 Protected float setVar (int a, int b, float c) (return c;)

考题 Given:  1. public class Method Over {  2. public void set Var (int a, int b, float c) {  3. }  4. }   Which two overload the set Var method()?A、 private void set Var(int a, float c, int b) {}B、 protected void set Var(int a, int b, float c) {}C、 public int set Var(int a, float c, int b) {return a:}D、 public int set Var(int a, int b, float c) {return a:}E、 protected float set Var(int a, int b, float c) {return c:}

考题 Assume that country is set for each class.  Given:  10. public class Money {  11. private String country, name;  12. public getCountry() { return country; }  13.}  and:  24. class Yen extends Money {  25. public String getCountry() { return super.country; }  26. }  27.  28. class Euro extends Money {  29. public String getCountry(String timeZone) {  30. return super.getCountry();  31. }  32. }  Which two are correct?()A、 Yen returns correct values.B、 Euro returns correct values.C、 An exception is thrown at runtime.D、 Yen and Euro both return correct values.E、 Compilation fails because of an error at line 25.F、 Compilation fails because of an error at line 30.

考题 类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 BaseClass{  private float x= 1.0f;  protected void setVar (float f) {x = f;}  }  class SubClass extends BaseClass   {  private float x = 2.0f;  //insert code here  }   Which two are valid examples of method overriding?()        A、 Void setVar(float f) {x = f;}B、 Public void setVar(int f) {x = f;}C、 Public void setVar(float f) {x = f;}D、 Public double setVar(float f) {x = f;}E、 Public final void setVar(float f) {x = f;}F、 Protected float setVar() {x=3.0f; return 3.0f; }

考题 1. class super {  2. public float getNum() {return 3.0f;}  3. }  4.    5. public class Sub extends Super { 6.   7. }   Which method, placed at line 6, will cause a compiler error?()  A、  Public float getNum()   {return 4.0f; }B、  Public void getNum ()  { }C、  Public void getNum (double d)   { }D、  Public double getNum (float d) {retrun 4.0f; }

考题 单选题class Super {  public Integer getLenght() { return new Integer(4); } }  public class Sub extends Super {  public Long GetLenght() { return new Long(5); }  public static void main(String[] args) { Super sooper = new Super();  Sub sub = new Sub();  System.out.println(  sooper.getLenght().toString() + “,” +  sub.getLenght().toString() ); } }  What is the output?()A  4,4B  4,5C  5,4D  5,5E  Compilation fails.

考题 单选题类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;}

考题 单选题public class Person {  private String name, comment;  private int age;  public Person(String n, int a, String c) {  name = n; age = a; comment = c;  }  public boolean equals(Object o) {  if(! (o instanceof Person)) return false;  Person p = (Person)o;  return age == p.age  name.equals(p.name);  }  }  What is the appropriate definition of the hashCode method in class Person?()A  return super.hashCode();B  return name.hashCode() + age * 7;C  return name.hashCode() + comment.hashCode() /2;D  return name.hashCode() + comment.hashCode() / 2 - age * 3;

考题 单选题1. class super {  2. public float getNum() {return 3.0f;}  3. }  4.    5. public class Sub extends Super { 6.   7. }   Which method, placed at line 6, will cause a compiler error?()A   Public float getNum()   {return 4.0f; }B   Public void getNum ()  { }C   Public void getNum (double d)   { }D   Public double getNum (float d) {retrun 4.0f; }

考题 单选题class super {  public int getLength()  {return 4;}  }  public class Sub extends Super {  public long getLength() {return 5;}  public static void main (String[]args)  {  super sooper = new Super ();  Sub sub = new Sub();  System.out.printIn(  sooper.getLength()+ “,” + sub.getLength()   };  }  What is the output?()A  4, 4B  4, 5C  5, 4D  5, 5E  The code will not compile.

考题 单选题1. class Super {  2. public float getNum() { return 3.0f; }  3. }  4.   5. public class Sub extends Super {  6.   7. }  Which method, placed at line6, causes compilation to fail?()A  public void getNum(){}B  public void getNum(double d){}C  public float getNum() { return 4.0f; }D  public double getNum(float d) { return 4.0d; }

考题 多选题class BaseClass{  private float x= 1.0f;  protected void setVar (float f) {x = f;}  }  class SubClass extends BaseClass   {  private float x = 2.0f;  //insert code here  }   Which two are valid examples of method overriding?()AVoid setVar(float f) {x = f;}BPublic void setVar(int f) {x = f;}CPublic void setVar(float f) {x = f;}DPublic double setVar(float f) {x = f;}EPublic final void setVar(float f) {x = f;}FProtected float setVar() {x=3.0f; return 3.0f; }

考题 多选题class BaseClass{   private float x= 1.0f;   protected void setVar (float f) {x = f;}   }   class SubClass exyends BaseClass {   private float x = 2.0f;   //insert code here  8. }   Which two are valid examples of method overriding?()AVoid setVar(float f) {x = f;}BPublic void setVar(int f) {x = f;}CPublic void setVar(float f) {x = f;}DPublic double setVar(float f) {x = f;}EPublic final void setVar(float f) {x = f;}FProtected float setVar() {x=3.0f; return 3.0f; }

考题 多选题public class MethodOver {   public void setVar (int a, int b, float c) {   }   }   Which two overload the setVar method?()APrivate void setVar (int a, float c, int b) {}BProtected void setVar (int a, int b, float c) {}CPublic int setVar (int a, float c, int b) (return a;)DPublic int setVar (int a, int b, float c) (return a;)EProtected float setVar (int a, int b, float c) (return c;)

考题 多选题public class Car {  private int wheelCount;  private String vin;  public Car(String vin) {  this.vin = vin;  this.wheelCount = 4;  }  public String drive() {  return “zoom-zoom”;  }  public String getInfo() {  return “VIN: “+ vin + “wheels: “+ wheelCount;  }  }  And:  public class MeGo extends Car {  public MeGo(String vin) {  this.wheelCount = 3;  }  }  What two must the programmer do to correct the compilation errors?()Ainsert a call to this() in the Car constructorBinsert a call to this() in the MeGo constructorCinsert a call to super() in the MeGo constructorDinsert a call to super(vin) in the MeGo constructorEchange the wheelCount variable in Car to protectedFchange line 3 in the MeGo class to super.wheelCount = 3;