JAVAOOP复习题笔试

2019-04-10 08:09

内测/月考

JAVAOOP复习题

类型:(笔试)

日期:

范围:内测/月考

时长:1小时

总分数:100 分

姓名:

证件号码: 准考证号:

理论部分

注意:考试结束试卷必须交回,答案填写在答题卡上

第 1 页 共 18 页

内测/月考

1. .给定两个java程序,如下:Text.java的编译运行结果是(选一项) pubilc interface Face{ int count = 40; }

pubilc class Text implements Face{ private static int counter;

pubilc static void main(String[]args){ System.out.println( counter ); } } A、40 B、41 C、0 D、1

2. Java程序中读入用户输入的一个值,要求创建一个自定义的异常,如果输入值大于10,使用throw语句显式地引发异常,异常输出信息为“something’s wrong!”,语句为(选一项) A、if (I>10) throw Exception(\’s wrong!\B、if (I>10) throw Exception e (\’s wrong!\C、if (I>10) throw new Exception(\’s wrong!\ D、if (I>10) throw new Exception e (\’s wrong!\

3. Java程序中类的定义如下: class Demo {

private int[] count; public Demo(){ count=new int[10]; }

public void setCount(int ct,int n){ count[n]=ct; }

public int getCount(int n){ return count[n]; }

public void showCount(int n){

System.out.println(\ } }

在创建Demo类的实例后,通过调用showCount(9)方法得到的显示结果是(选一项) A、Count is 0 B、Count is null C、编译错误 D、运行时错误

第 2 页 共 18 页

内测/月考

4. java程序中有如下代码:

DataInputStream din = new DataInputStream (

new BufferedInputStream(new FileInputStream(\

假设在employee.dat文件中只有如下一段字符:abcdefg。则:System.out.println(din.read())在屏幕上打印(选一项) A、A B、B C、97 D、98

5. java语言中,下列处理输出操作的所有类的基础的是(选一项) A、DataOutput B、OutputStream C、BufferedOutputStream D、IOStream

6. Java中,使用()修饰符时,一个类能被同一包或不同包中的其他类访问。(选一项) A、private B、protected C、public D、friendly

7. public class MyClass1{

public static void main (String argv[]){} _____ class MyInner {} }

在以上java代码中的横线上,不可放置()修饰符。(选一项) A、public B、private C、static D、friend

8. public class Test {

public static void main(String args[]){ EqTest e = new EqTest(); e.show(); } }

class EqTest{ String s = \ String s2 = \ public void show(){ //在这儿放置测试代码 {System.out.println(\相等\

第 3 页 共 18 页

内测/月考

else

{System.out.println(\不相等\ } }

在上面的Java代码的注释行位置,放置()测试代码能输出“相等”结果。(选一项) A、if(s==s2) B、if(s.equals(s2))

C、if(s.equalsIgnoreCase(s2)) D、if(s.noCaseMatch(s2)) 9.

包pack1的类class1中有成员方法: protected void method_1(){?}, private void method_2(){…},

public void method_3(){?}和void method_4(){?},在包pack2中的类class2是class1的子类,你在class2中可以调用方法(选两项) A、method_1 B、method_2 C、method_3 D、method_4

10. 编译并运行下面的Java程序:

class A{ int var1=1; int var2;

public static void main(String[] args){ int var3=3; A a = new A();

System.out.println(a.var1+a.var2+var3); } }

将产生( )结果。(选一项) A、0 B、4 C、3

D、代码无法编译,因为var2根本没有被初始化

11. 编译并运行下面的Java代码段

char c = 'a'; switch (c) {

case 'a': System.out.println(\ default: System.out.println(\ }

输出结果是(选一项)

A、代码无法编译,因为switch语句没有一个合法的表达式

第 4 页 共 18 页

内测/月考

B、a default C、a D、default

12. 分析下列Java代码:

class A{

public static void main(String[] args){ method(); }

static void method(){ try{

System.out.println(\ } finally{

System.out.println(\ } } }

编译运行后,输出结果是(选一项) A、“Hello” B、“good-bye” C、“Hello good-bye” D、代码不能编译

13. 分析下面的Java程序:

public class ExceptionTest {

public static void main(String[] args) throws Exception { try {

throw new Exception(); }

catch(Exception e){

System.out.println(\ }

System.out.println(\ } }

输出结果为(选一项) A、Caught in main()nothing B、Caught in main() C、nothing D、没有任何输出

14. 给定 Java 代码如下 , 要打印出list中存储的内容,以下语句正确的是(选两项)

ArrayList list= new ArrayList();

第 5 页 共 18 页


JAVAOOP复习题笔试.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:图书馆管理系统-大作业

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: