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?()
第1题:
下面程序输出的结果为
#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 B
B.CLASS A CLASS B CLASS B
C.CLASS A CLASS B CLASS A CLASS B
D.CLASS A CLASS B CLASS B CLASS B
第2题:
下面程序输出的结果为 #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 B
B.CLASS A CLASS B CLASS A CLASS B
C.CLASS A CLASS B CLASS B
D.CLASS A CLASS B
第3题:
A.insert a call to this() in the Car constructor
B.insert a call to this() in the MeGo constructor
C.insert a call to super() in the MeGo constructor
D.insert a call to super(vin) in the MeGo constructor
E.change the wheelCount variable in Car to protected
F.change line 3 in the MeGo class to super.wheelCount = 3;
第4题:
第5题:
下列程序的输出结果是
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:7
B.m andn:6 7 p:8
C.m and n:7 8 p:6
D.m and n:8 7 p:6
第6题:
已知: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类
第7题:
下面程序输出的结果为( )。 #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 B
B.CLASS A CLASS B CLASS B
C.CLASS A ClASS B
D.CLASS A CLASS B CLASS A CLASS B CLASS B CLASS B
第8题:
下面程序输出的结果为 #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 B
B.CLASS A CLASS B CLASS B
C.CLASS A CLASS B CLASS A CLASS B
D.CLASS A CLASS B CLASS B CLASS B
第9题:
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
第10题:
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?()