程序: class MyDate{ private int year; private int month; private int day; public MyDate(int year,int month,int day){ this.year=year; this.month=month; this.day=day; } //Override Method } 为了让new MyDate(1980,11,9)==new MyDate(1980,11,9) 返回true,必须在Override Method处覆盖哪个方法?()
第1题:
有如下程序:#include<iostream>using namespace std;class test{private: int a;public: test(){cout<<"constructor"<<endl;} test(int a){cout<<a<<endl;} test(const test&_test) { a=_test.a; cout<<"copy constructor"<<en+dl; } ~test(){cout<<"destructor"<<endl;}};int main(){ test A(3); rerun 0;}运行时输出的结果是
A.3
B.constructor destructor
C.copy constructor destructor
D.3 destructor
第2题:
下列程序实现对ZIP文件file.zip的检索,在横线处填入正确的语句( )。
A.en=zis.getNextEntry( )
B.en==zis.getNextEntry( )
C.en=zis.getEntry( )
D.zis.getNextEntry( )
第3题:
有以下程序:
include<iostream>
using namespace std;
class Base
{
public:
Base()
{
K=0;
}
int x;
};
class Derivedl:virtual public Base
{
public:
Derivedl()
{
x=10;
}
};
class Derived2:virtua1 public Base
第4题:
下面程序输出的结果为 #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
第5题:
下面程序输出的结果为
#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
第6题:
有以下程序:
include<iostream.h>
class A
{
int x;
public:
A(int a)
{
x=a;
}
friend class B;
}
class B{
public:
void print(A a){
a. x--;
cout<<a.x<<end1;
}
};
void main()
{
A a(10);
B b;
b.print(a) ;
}
程序执行后的输出结果是【 】。
第7题:
下面程序输出的结果为 #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
第8题:
下面程序的输出结果是( )。 main() {struct m1{int a;int b;}en[2]={1,3,2,7); printf("%d\n",en[0].b/en[0].a*en[1].a);
A.6
B.0
C.1
D.3
第9题:
下列程序片段中,能通过编译的是( )。
A.public abstract class Animal{ public void speak;}
B.public abstract class Animal{ public void speak{);}
C.public class Animal{ pubilc abstract void speak;}
D.public abstract class Animal{ pubile abstract void speak{};}
第10题:
以下程序的执行结果为______。
include<iostream.h>
class A
{public:A(){cout<<“a”;}
~A(){cout<<“b”;}};
class B:public A
{public:
B(){cout<<“c”;)
~B(){cout<<“d”;}};
void main()
{B b;}
第11题:
hashCode
equals
toString
notify
第12题:
hashCode
equals
toString
notify
第13题:
以下程序的执行结果为______。
include<iostream>
using namespace std;
class base
{
public:
virtual void who()
{
cout<<"base class"<<endl;
}
};
class derivel:public base
{
public:
void who()
{
cout<<"d
第14题:
有如下程序: #include<iostream> using namespace std; class A { public: A(){cout<<"A";} }; class B<public:B(){cout<<"B";)); class C:public A { B b; public: C(){cout<<"C";} }; int main(){Cobj;retum 0;} 执行后的输出结果是
A.CBA
B.BAC
C.ACB
D.ABC
第15题:
有如下程序: #include<iostream> using namespace std; class BASE{ public: ~BASE( ){cout<<"BASE";} }; class DERIVED:public BASE{ public: ~DERIVED( ){cout<<"DERIVED";} }; int main( ){DERIVED x;return 0;} 程序的输出结果是
A.BASE
B.DERIVED
C.BASEDERIVED
D.DERIVEDBASE
第16题:
编译下面源程序会得到—文件。 class A1 { } class A2 { } public class B { public static void main(String args[]) { } }
A.只有B.class文件
B.只有A1.class和A2.class文件
C.有A1.class、A2.class和B.class文件
D.编译不成功
第17题:
对于模板定义关键宁class和typename说法不正确的是( )。
A.程序中的class并不能都替换为typename
B.class和typename都可互相替换
C.程序中的typename都能替换为class
D.程序中的部分class可以替换为typename
第18题:
有如下程序:
include<iostream>
using namespaee std;
class A{
public:
A( ){cout<<"A";}
~A( ){cout<<"A";}
};
class B{
A a;
public:
B( ){cout<<"B";}
~B( )t cout<<"B";}
};
int main( ){
B b;
return 0;
}
程序的输出结果是______。
第19题:
下列程序实现对ZIP文件file.zip的检索,在横线处 填入正确的语句( )。 package test; importjava.io.*; import java.util.*; import java.util.zip.*; public class Exam { public static void main(String[]args){ try{ FileInputStream fis=new FileInputStream("test/file. zip"); ZipInputStream zis=new ZiplnputStream(fis); ZipEntry an; while(( )!=null){ en.getName; zis.closeEntry; } zis.close: } catch(Exception e){ printStackTrace; } } }
A.en=zis.getNextEntry
B.en= =zis.getNextEntry
C.en=zis.getEntry
D.zis.getNextEntry
第20题:
下面程序输出的结果为( )。 #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
第21题:
下列程序实现对ZIP文件file.zip的检索,在横线处填入正确的语句 package test; import java.io.*: import java.util.*; import java.util.zip.*; public class Exam { public static void main(String[])args){ try{ FileInputStream fis=new FileInputStream("test/file.zip"); ZipInputStreamzis=new ZipInputStream(fis); ZipEntry en; while ((_____)!=null){ en.getName(); zis.closeEntry(); } zis.close(); } catch(Exception e) { e.printStackTrace(); } } }
A.en = zis.getNextEntry()
B.en = zis.getNextEntry()
C.en = zis.getEntry()
D.zis.getNextEntry()
第22题:
在下面程序的横线处填上适当的内容,使程序执行后的输出结果为ABCD。
include<iostream>
using namespace std;
class A
{
public: A(){cout<<'A';}
};
class B:【 】
{
public:B(){cout<<'B';)
};
class C:【 】
{
public;C(){cout<<'C';}
};
class D:public B,public C
{
public:D(){cout<<'D';}
};
void main(){D obi;}
第23题:
public class B inherit A
public class B :: A
public class B : A
public class B from A