网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
class Super { public int i = 0; public Super(String text) { i = 1; } } public class Sub extends Super { public Sub(String text) { i = 2; } public static void main(String args[]) { Sub sub = new Sub(“Hello”); System.out.println(sub.i); } } What is the result?()
- A、 0
- B、 1
- C、 2
- D、 Compilation fails.
参考答案
更多 “ class Super { public int i = 0; public Super(String text) { i = 1; } } public class Sub extends Super { public Sub(String text) { i = 2; } public static void main(String args[]) { Sub sub = new Sub(“Hello”); System.out.println(sub.i); } } What is the result?() A、 0B、 1C、 2D、 Compilation fails.” 相关考题
考题
Click the Exhibit button. What two must the programmer do to correct the compilation errors? ()
A.insert a call to this() in the Car constructorB.insert a call to this() in the MeGo constructorC.insert a call to super() in the MeGo constructorD.insert a call to super(vin) in the MeGo constructorE.change the wheelCount variable in Car to protectedF.change line 3 in the MeGo class to super.wheelCount = 3;
考题
下面程序输出的结果为 #include"iostream.h" class A { public: A(){cout<<"CLASSA"<<endl;} ~A() {} }; class B:public A { public: B(){cout<<"CLASSB"<<endl;} ~B() {} }; void main() { A * p; p=new B; B *q; q=new B; }A.CLASS A CLASS BB.CLASS A CLASS B CLASS BC.CLASS A CLASS B CLASS A CLASS BD.CLASS A CLASS B CLASS B CLASS B
考题
下面程序输出的结果为#include"iostream.h"class A{public:A( ){cout<<"CLASS A"<<endl;}~A( ){}};class B:public A{public:B( ){cout<<"CLASS B"<<endl;}~B( ){}};void main( ){A*p;p=new B;B *q;q=new B;}A.CLASS A CLASS BB.CLASS A CLASS B CLASS BC.CLASS A CLASS B CLASS A CLASS BD.CLASS A CLASS B CLASS B CLASS B
考题
已知:Manager extends Employee观察:public Manager(String n,double s,int year,int month,int day) { super(n,s,year,month,day); bonus=0; }其中super是 ( )A.Object类B.Manager类C.Employee类D.Class类
考题
下面程序输出的结果为 #include"iostream.h” class A { public: A(){cout<<"CLASSA"<<endl;} ~A() {} }; class B:public A { public: B(){cout<<"CLASS B"<<endl;} ~B(){} }; void main() { A*p; p=new B;A.CLASS A CLASS B CLASS B CLASS BB.CLASS A CLASS B CLASS A CLASS BC.CLASS A CLASS B CLASS BD.CLASS A CLASS B
考题
下面程序输出的结果为( )。 #inClUde”iostream.h” Class A {public: A(){cout<<“CLASS A”<<endl;} ~A()<)}; class B:public A {public: B(){cout<<”CLASSB”<<endl;} ~B(){}}; void main() {A*p; p=new B; B *q; q=new B;}A.CLASS A CLASS BB.CLASS A CLASS B CLASS BC.CLASS A ClASS BD.CLASS A CLASS B CLASS A CLASS B CLASS B CLASS B
考题
下列程序的输出结果是class Father{int m.n;Father(int a,int B){ m=a;n=b}void show ( ){System.out.println("m and n:"+m+" "+n);}}class Son extends Father{int p;Son (int a,int b,int C){ super(a,B) ;p=c;}void show(){supur.show( );System.out.println("p:"+p);}}class Test {public static void main (String args[ ]){ Son s:new Son(6,7,8);s.show( );}}A.m and n:6 8 p:7B.m andn:6 7 p:8C.m and n:7 8 p:6D.m and n:8 7 p:6
考题
The lower-level classes (known as subclasses or derived classes) ( ) state and behavior from the higher-level class (known as a super class or base class).A.request B.inherit C.invoke D.accept
考题
The lower-level classes(known as subclasses or derived classes) ( )state andbehavior from the higher-level class(known as a super class or base class).A.request
B.inherit
C.invoke
D.accept
考题
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;
考题
class A { A() { } } class B extends A { } Which two statements are true?()A、 Class B’s constructor is public.B、 Class B’s constructor has no arguments.C、 Class B’s constructor includes a call to this().D、 Class B’s constructor includes a call to super().
考题
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.
考题
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; }
考题
In the Java API documentation which sections are included in a class document?() A、 The description of the class and its purposeB、 A list of methods in its super classC、 A list of member variableD、 The class hierarchy
考题
多选题In the Java API documentation which sections are included in a class document?()AThe description of the class and its purposeBA list of methods in its super classCA list of member variableDThe class hierarchy
考题
单选题class Super { public int i = 0; public Super(String text) { i = 1; } } public class Sub extends Super { public Sub(String text) { i = 2; } public static void main(String args[]) { Sub sub = new Sub(“Hello”); System.out.println(sub.i); } } What is the result?()A
0B
1C
2D
Compilation fails.
考题
单选题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.
考题
多选题class A { A() { } } class B extends A { } Which two statements are true?()AClass B’s constructor is public.BClass B’s constructor has no arguments.CClass B’s constructor includes a call to this().DClass B’s constructor includes a call to super().
考题
多选题1. class BigDog extends Dog { 2. // insert code here 3. } 分别插入到第 2 行,哪二项可以编译?()ABigDog() { super(); this(); }BBigDog() { String name = Fido; super(); }CBigDog() { super(); String name = Fido; }Dprivate BigDog() { super();}
考题
单选题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.
考题
单选题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 I = 0; public super (string text) ( I = 1 ) ) public class sub extends super ( public sub (string text) ( i= 2 ) public static void main (straing args) ( sub sub = new sub (“Hello”); system.out. PrintIn(sub.i); ) ) What is the result?()A
Compilation will fail.B
Compilation will succeed and the program will print “0”C
Compilation will succeed and the program will print “1”D
Compilation will succeed and the program will print “2”
考题
多选题1. class Super { 2. private int a; 3. protected Super(int a) { this.a = a; } 4. } ..... 11. class Sub extends Super { 12. public Sub(int a) { super(a); } 13. public Sub() { this.a= 5; } 14. } Which two, independently, will allow Sub to compile?()AChange line 2 to: public int a;BChange line 2 to: protected int a;CChange line 13 to: public Sub() { this(5); }DChange line 13 to: public Sub() { super(5); }EChange line 13 to: public Sub() { super(a); }
考题
多选题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;
热门标签
最新试卷