计算机科学与技术面向对象程序设计 复习提纲(含答案)

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

面向对象程序设计复习提纲

1. 下列叙述中正确的是()

A) Java是不区分英文字母大小写的,源文件名与程序类名不允许相同

B) Java语言以方法为程序的基本单位

C) Applet是Java的一类特殊应用程序,它嵌入HTML中,随主页发布到互联网D) 以//符开始的为多行注释语句

2. Java语言的许多特点中,下列()特点是C++语言所不具备的

A) 高性能B) 跨平台C) 面向对象D) 有类库

3. Java源文件中最多只能有一个()类,其他类的个数不限

A)abstract B) public C) final D) interface

4. Java语言中,()是所有类的根类

A) Object B) Root C) Thread D) Applet

5. Java语言中,字符变量以char类型表示,它在内存中占()位bit

A) 8 B) 16 C) 32 D) 2

6. 下列叙述中,()是正确的

A) 类是变量和方法的集合体B) 数组是无序数据的集合

C) 抽象类可以实例化D) 类成员数据必须是公有的

7. 下列关于方法形参的叙述中,()是正确的

A) 必须有多个B) 至少有一个C) 可以没有D) 只能是简单变量

8. 构造方法在()时候被调用

A) 类定义时B) 创建对象时 C) 调用对象方法时D) 使用对象的变量时9.下列关于继承的叙述中,()是正确的

A) 子类能继承父类的所有方法和状态

B) 子类能继承父类的非私有方法和状态

C) 子类只能继承父类的public方法和状态

D) 子类只能继承父类的方法,而不继承状态

10. 下列关于接口的叙述中,()是正确的

A) 接口与抽象类是相同的概念

B) 接口之间不能有继承关系

C) 一个类只能实现一个接口

D) 接口中只含有抽象方法和常量

二、判断题

()1、Java的各种数据类型占用固定长度,与具体的软硬件平台环境无关。

()2、用“+”可以实现字符串的拼接,用“-”可以从一个字符串中去除一个字符子串。

()3、A class can implement as many interfaces as needed.

()4、A subclass inherits all methods ( including the constructor ) from the superclass.

()5、Java程序里,创建新的类对象用关键字new,回收无用的类对象使用关键字free。

三、程序改错题

1、class MyClass{

int var=100;

static int getVar(){

return var;

}

}

2、public class MyClass{

int data;

void MyClass(int d){

data=d;

}

}

3、public class A implements Runnable{

Thread mt=Thread(this);

mt.start();

public void run(){

System.out.println("I am alive now");

}

}

4、public class IfElse{

public static void main(String args[]){

if(odd(5))System.out.println("odd");

else System.out.println("even");

}

public static int odd(int x){return x%2;}

}

四、读程序,写出其运行结果

1、class Parent{

void printMe(){

System.out.println("parent");

}

}

class Child extends Parent{

void printMe(){

System.out.println("child");

}

void printAll(){

super.printMe();

this.printMe();

printMe();

}

}

public class A{

public static void main(String args[]){

Child myC=new Child();

myC.printAll();

}

}

2、已有Bird类的定义如下:

package abcde;

public class Bird{

protected static int referenceCount=0;

public Bird(){

referenceCount++;

}

protected void fly(){}

static int getReCount(){

return referenceCount;

}

}

有类Nightingale的定义如下:

package singers;

class Nightingale extends abcde.Bird{

Nightingale(){

referenceCount++;

}

public static void main(String args[]){

System.out.print("Before:"+referenceCount);

Nightingale florence=new Nightingale();

System.out.println("After:"+referenceCount);

florence.fly();

}

}

3、class Cruncher{

void crunch(int i){System.out.println("int version");}

void crunch(String s){System.out.println("String version");} public static void main(String args[]){

Cruncher crun=new Cruncher();

char ch='p';

crun.crunch(ch);

}

}

相关文档
最新文档