在下列程序的划线处应填入的语句是( )。 class Person { private int a: } public class Man extends Person{ public int b; public static void main(String arg []){ Person p=newPerson(); Man t=new Man(); int i; _________________ } }
A.i=w;
B.i=b;
C.i=P.a;
D.i=t.b;
第1题:
能将程序补充完整的选项是______。 class Person{ private int a; phblic int change(int m){return m;} } public class Teacher extends Person{ public int b; public static void main(String arg[ ]){ Person p=new Person( ); Teacher t=new Teacher( ); int i; ______; } }
A.i=m
B.i=b
C.i=p.a
D.i=p.change(50)
第2题:
为完成下面的程序,应在划线处填入的语句是 #include<iostream> using namespace std; class Base { private: int x; public: Base (int i) { x=i; } ~Base(){} }; class Derived:public Base { public: ______________//完成类Derive构造函数的定义 }; int main() { Derived Obj; return 0; }
A.Derived(int i):Base(i){}
B.Derived(){}
C.void Derived (int i):Base(i){}
D.Derived(int i){Base(i);}
第3题:
阅读下面代码 abstract class Person { public Person(String n) { name=n; } public______String getDescription(); public String getName() { return name; } private String name; } 在下画线处应填入的修饰符是
A.static
B.abstract
C.protected
D.final
第4题:
根据下面的程序,可以在主程序中使用的合法语句是( )。 #include <iostream> using namespace std; class Person{ int age; public: void SetAge(int x){age=x;} void ShowAge(){cout<<"the Person's age is" <<age;} }; class Student:private Person{ public:int study_code; }; void main(){ Student wangqiang; wangqiang.study_code=23; }
A.wangqiang.age=231
B.wangqiang.Setage(23)
C.wangqiang.ShowAge()
D.wangqiang.study_code=12
第5题:
在下列程序的划线处应填入的语句是 class Pemon { pnvate int a; } public class Man extends Person { public int b; public static void main(String arg[ ] ) { Person p = new Person( ); Man t = new Man( ); int i; ________ } }
A.i = w;
B.i = b;
C.i = p.a;
D.i = t.b;
第6题:
下列程序中需要清理动态分配的数组,划线处应有的语句是_______。
include<iostream.h>
class person
{
int age,tall;
public:
person( ){age=0;tall=40;cout<<"A baby is born."<<endl;}
person(int i){age=i;tall=40;cout<<"A old person."<<endl;}
person(int i,int j){age=i;tall=j;cout<<"a old person with tall."<<endl;)
~person( ){cout<<"person dead."<<endl;}
void show( )
{
cout<<"age="<<age<<",tall="<<tall<<endl;
}
};
void main( )
{
person*ptr;
ptr=new person[3];
ptr[0]=person( );
ptr[1]=person(18);
ptr[2]=person(20,120);
for(int i=0;i<3;i++)
ptr[i].show( );
______
}
第7题:
为了支持压栈线程与弹栈线程之间的交互与同步,在程序的下画线处依次填入的语句是( )。 public class IntStack{ private int idx=0; private int[]data=new int[8]; public void push(int i){ data[idx]=i: idx++; … … }
A.synchronized notify
B.synchronized this.wait
C.synchronized this.notify
D.Serializable sleep
第8题:
下列程序编译错误,是由于划线处缺少某个语句,该语句是______。
include<iostream.h>
class A
{
private:
int numl;
public:
A( ):numl(0){}
A(int i):numl(i){}
};
class B
{
private:
int num2;
public:
B( ):num2(0){}
B(int i):num2(i){}
int my_math(A obj1, B obj2);
};
int B::my_math(A obj1,B obj2)
{
return(obj1.numl+obj2.num2);
}
void main(void)
{
A objl(4);
B obj,obj2(5);
cout<<"obj1+obj2:"<<obj.my_math(obj1,obj2);
}
第9题:
Which three demonstrate an “is a” relationship?()
第10题:
Which two demonstrate an “is a” relationship?()
第11题:
i = m;
i = b;
i = p.a;
i = p.change(30);
i = t.b.
第12题:
public class Circle implements Shape { private int radius; }
public abstract class Circle extends Shape { private int radius; }
public class Circle extends Shape { private int radius; public void draw(); }
public abstract class Circle implements Shape { private int radius; public void draw(); }
public class Circle extends Shape { private int radius;public void draw() {/* code here */} }
public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }
第13题:
阅读下列代码段 abstract class Person{ public Person(String n){ name=n; } public______String getDescription(); public String getName(){ } private String name; } 在下画线处应填入的修饰符是
A.static
B.abstract
C.protected
D.final
第14题:
下面这个程序的结果是
#include<iostream.h>
class A
{
private:
int a;
public:
void seta( ) ;int geta( ) ;};
void A: :seta( )
{ a=1;}
int A: :geta( )
{ retum a;}
class B
{ private:
int a;
public:
void seta( ) ;int geta( ) ;};
void B: :seta( )
{a=2;}
int B: :geta( )
{return a;}
class C: public A,public B
{ private:
int b;
public:
void display( ) ;};
void C: :display( )
{ int b=geta( ) ;
cout < < b;}
void main( )
{ C c;
c. seta( ) ;
c. display( ) ;}
A.1
B.2
C.随机输出1或2
D.程序有错
第15题:
为使该程序执行结果为10,那么应该在程序划线处填入的语句是( )。 #include<iostream> using namespace std; class MyClass { public: MyClass (int a) { x=a; } ___________ //取x值 private: int x; }; int main() { MyClass my(10); cout<<my.GetNum()<<end1; return 0; }
A.return x;
B.int GetNum(){ return x;}
C.intreturn x;
D.void GetNum(){return x;}
第16题:
在下列程序的划线处应填入的语句是class Person { private int a;}public class Man extends Person{ public int b; public static void main (String arg []){ Person p=new Person(); Man t=new Man(); int i: }}
A.i=w;
B.i=b
C.i=p.a;
D.i=t.b;
第17题:
阅读下面实现堆栈类并发控制的部分代码 public class DataStack{ private int idx=0; private int[]data=new int[8]; public void push(int i){ . ________________{ data[idx]=i; idx + +; } } } …… } 在程序下画线处填入正确选项是
A.synchronized
B.synchronized(this)
C.synchronized()
D.synchronized(idx)
第18题:
为完成下面的程序,应在划线处填入的语句是( )。 #include <iostream> using namespace std; class Base { private: int x; public: Base(int i) { x=i; } ~Base(){} }; class Derived : public Base { public: _______________ //完成类Derive构造函数的定义 }; int main() { Derived Obj; return 0; }
A.Derived(int i):Base(i){}
B.Derived(){}
C.voidDerived(int i):Base(0){}
D.Derived(int i){Base(i);}
第19题:
阅读下面实现堆栈类并发控制的部分代码 public class DataStack } private int idx=0; private int[] data=new int[8]; public void push(int i) { ______ { data[idx]=I: idx++; } } … } 程序中下画线处应填入的正确选项是
A.synchronized
B.synchronized(this)
C.synchronized()
D.synchronized(idx)
第20题:
( 31 ) 为了支持压栈线程与弹栈线程之间的交互与同步 , 在程序的下划线处依次填入的语句是
public class IntStack{
private int idx=0;
private int[] data=new int[8];
public void push(int i){
data[idx]=i;
idx++;
}
__________
......
}
A ) synchronized()
notify()
B ) synchronized()
this.wait()
C ) synchronized()
this.notify()
D ) synchronized()
sleep()
第21题:
Which the two demonstrate an “is a” relationship?()
第22题:
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?()
第23题:
public class X { } public class Y extends X { }
public interface Shape { } public interface Rectangle extends Shape{ }
public interface Color { } public class Shape { private Color color; }
public interface Species { } public class Animal { private Species species; }
public class Person { } public class Employee { public Employee(Person person) { }
interface Component { } class Container implements Component { private Component[] children; }