大学java期末考试试卷.pdf
13、下面选项中哪个不会导致正在运行的线程中止运行A线程执行wait。方法;B该线程产生一个新线程;C 一个更高优先级的线程进入可运行状态D 有 InterruputedExceptin 异常抛出。1 4下面哪个类的构造函数中需要“模 式(m ode)参数如r”或 者“rw”A DatalnputStreamB InputStreamCFileD RandomAccesFile15、java中,用package语句说明一个包时,该包的层次结构必须是:A、与文件的结构相同 B、与文件目录的层次相同C、与文件类型相同 D、与文件大小相同二、判断题:(共10题,每题1分,总计10分)1、java程序中,定义为public的类名可以不与文件名一致。2、如果一个类没有访问控制符,则它只能被同一个包中的对象访问和引用。3、类在实现接口中定义的方法时,不必显式的使用public修饰符。4、抽象类中的方法可以是抽象的也可以不是抽象的。5、在java坐标系中,x的值是从左往右增长6、在一个顺序文件中,如果文件位置指针要指向一个文件开始位置以外的地方,就必须关闭该文件,然后再重新打开它并从文件开始位置读。7、当String对象用=比较时,如果String包括相同的值则结果是true8、一个String类的对象在创建后可以被修改9、java提供了多继承机制10、如果一个线程被停止了,则它是不可运行的三、程序填空题:(共10题,每题3分,总计3 0分)1、阅读以下程序,输出结果为。class Qlpublic static void main(String args)double d=1.23;Dec dec=new Dec();dec.decrement(d);System.out.println(d);)classs Decpublic void decrement(double decMe)decMe=decMe 0.1;)2、以下程序的输出结果为 opublic class Short public static void main(String args)StringBuffer s=new StringBufferCHeHo);if(s.length()5)&(s.append(there).equals(False)System.out.printlnCvalue is+s);)以下程序段的输出结果为int x=0,y=4,z=5;if(x2)if(y5)System.out.printlnCMessage three);)else System.out.printlnCMessage four);)以下程序段的输出结果为_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _int j=2;switch(j)case 2:System.out.print(66Value is two.);case 2+1:System.out.printlnCValue is three.);break;default:System.out.printlnCvalue is+j);break;)5、阅读以下程序段:class Parentvoid printMe()System.out.printlnC4parenf,);class Child extends Parentvoid printMe()|System.out.println(child);)void printAll()(super.printMe();this.printMe();printMe();)public class Test_this(public static void main(String args)(Child myC=new Child();myC.printAll();输出结果为;6、以下程序段的输出结果为_ _ _ _ _ _ _ _ _ _ _ _ _public class EqualsMethod public static void main(String args)Integer nl=new Integer(47);Integer n2=new Integer(47);System.out.print(n 1 =n2);System.out.print(J);System.out.println(nl!=n2);7、已有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.printCBeforer+referenceCount);Nightingale florence=new Nightingale();System.out.println(46 After:d-referenceCount);florence.fly();)8、以下程序段的输出结果为 oclass Crunchervoid crunch(int i)System.out.printlnCint version);)void crunch(String s)System.out.printlnCString version);)public static void main(String args)Cruncher crun=new Cruncher();char ch=,p,;crun.crunch(ch);)9、下面程序的输出结果是:class Art Art()System.out.println(nArt constructor);class Drawing extends Art DrawingO super();System.out.println(nDrawing constructor);)public class Cartoon extends Drawing Cartoon()super();System.out.println(nCartoon constructor);)public static void main(String args)Cartoon x=new Cartoon();10、下面程序的输出结果是:class Question 1(public static void main(String args)(for(int i=0;i AmlWrong implements RunnableThread mt=Thread(this);mt.start();void run()System.out.println(44I am alive now);五、程序编写题。(1题,10分)1、编写一个java程序,实现从键盘输入一个整数,输出该整数的最高位数.