java基本试题.doc

上传人:公**** 文档编号:549322244 上传时间:2023-01-21 格式:DOC 页数:11 大小:70.50KB
返回 下载 相关 举报
java基本试题.doc_第1页
第1页 / 共11页
java基本试题.doc_第2页
第2页 / 共11页
java基本试题.doc_第3页
第3页 / 共11页
java基本试题.doc_第4页
第4页 / 共11页
java基本试题.doc_第5页
第5页 / 共11页
点击查看更多>>
资源描述

《java基本试题.doc》由会员分享,可在线阅读,更多相关《java基本试题.doc(11页珍藏版)》请在金锄头文库上搜索。

1、重点题型:死记 2/11内嵌类Inner Class)1.内嵌类可以访问outer类的任何变量,包括私有的.2.静态inner类,只能访问outer类的任何static变量2.1内嵌类可以是final,abstract的3.方法内的内嵌类不能为static: void test() static class A XXXXX!4.方法内的内嵌类也不能带任何modifier,void test() public class A XXXXX!5.方法内的内嵌类只能访问方法内的final变量,但是,可以访问outer类的任何变量.6.匿名类不能有构造器,但声明时候带参数,相当于构造器的参数传递.cla

2、ss ABCclass ABCDprivate ABCD(int i)ABC test3()return new ABC();ABCD test4()return new ABCD(3);interface iiiiii test5()return new iii();/class BCD extends ABCD compile error,因为,看上面就知道,new iii();实际上匿名类实现了iii接口;new ABC();实际上是匿名类继承了ABC.8.? class A private A()System.out.println(a!);class B extends A没错!B实

3、例的时候会主动调用父类A的构造,即使是private的,看来也没问题!9.内部类可以有synchronized方法,那么锁是这个内部类,跟外部类没一点关系,内外分别的,在锁的问题上.10.外部类不能通过this被访问,this这时候应该指的是内部类,享用外部类的成员就直接用,不用加任何限定词11.如何用this呢?请看:class Outer int i;class Innerclass InnerInnervoid Test()Outer.this.i=1;看见了吧,类名.this.变量名,可以引用到i,12.注意这两种写法都可以Class Outer.Inner i = new Outer

4、().new Inner();或者, Class o= new Outer(); Class Outer.Inner i=o.new Inner(); ll 总结1、l Which is not a method of the class InputStream?A. int read(byte)B. void flush()C. void close()D. int available()答案:(b)题目:下面哪个不是InputStream类中的方法这个题目没有什么好说的,要求熟悉java API中的一些基本类,题目中的InputStream是所有输入流的父类,所有要很熟悉,参看JDK的AP

5、I文档。方法void flush()是缓冲输出流的基本方法,作用是强制将流缓冲区中的当前内容强制输出。l Which class is not subclass of FilterInputStream?A. DataInputStreamB. BufferedInputStreamC. PushbackInputStreamD. FileInputStream(d)题目:哪个不是FilterInputStream的子类。此题也是要求熟悉API基础类。Java基础API中的FilterInputStream 的已知子类有:BufferedInputStream, CheckedInputStr

6、eam, CipherInputStream, DataInputStream, DigestInputStream, InflaterInputStream, LineNumberInputStream, ProgressMonitorInputStream, PushbackInputStream 。l Which classes can be used as the argument of the constructor of the class FileInputStream?A. InputStreamB. FileC. FileOutputStreamD. String答案:(bd

7、)题目:哪些类可以作为FileInputStream类的构造方法的参数。此题同样是要求熟悉基础API,FileInputStream类的构造方法有三个,可接受的参数分别是:File、FileDescriptor、String类的一个对象。l Which classes can be used as the argument of the constructor of the class FilterInputStream?A. FilterOutputStreamB. FileC. InputStreamD. RandomAccessFile答案:(c)题目:哪些类可以作为FilterInpu

8、tStream类的构造方法的参数。FilterInputStream的构造方法只有一个,其参数是一个InputStream对象。l Which statements about thread are true?A. Once a thread is created, it can star running immediately.B. To use the start() method makes a thread runnable, but it does not necessarily start immediately.C. When a thread stops running bec

9、ause of pre-emptive, it is placed at the front end of the runnable queue.D. A thread may cease to be ready for a variety of reasons.(bd)题目:有关线程的哪些叙述是对的。A. 一旦一个线程被创建,它就立即开始运行。B. 使用start()方法可以使一个线程成为可运行的,但是它不一定立即开始运行。C. 当一个线程因为抢先机制而停止运行,它被放在可运行队列的前面。D. 一个线程可能因为不同的原因停止(cease)并进入就绪状态。一个新创建的线程并不是自动的开始运行的

10、,必须调用它的start()方法使之将线程放入可运行态(runnable state),这只是意味着该线程可为JVM的线程调度程序调度而不是意味着它可以立即运行。线程的调度是抢先式的,而不是分时间片式的。具有比当前运行线程高优先级的线程可以使当前线程停止运行而进入就绪状态,不同优先级的线程间是抢先式的,而同级线程间是轮转式的。一个线程停止运行可以是因为不同原因,可能是因为更高优先级线程的抢占,也可能是因为调用sleep()方法,而即使是因为抢先而停止也不一定就进入可运行队列的前面,因为同级线程是轮换式的,它的运行可能就是因为轮换,而它因抢占而停止后只能在轮换队列中排队而不能排在前面。l The

11、 method resume() is responsible for resuming which threads execution?A. The thread which is stopped by calling method stop()B. The thread which is stopped by calling method sleep()C. The thread which is stopped by calling method wait()D. The thread which is stopped by calling method suspend()答案:(d)

12、题目:方法resume()负责恢复哪些线程的执行。A. 通过调用stop()方法而停止的线程。 B. 通过调用sleep()方法而停止运行的线程。 C. 通过调用wait()方法而停止运行的线程。 D. 通过调用suspend()方法而停止运行的线程。Thread的API文档中的说明是该方法恢复被挂起的(suspended)线程。该方法首先调用该线程的无参的checkAccess() 方法,这可能在当前线程上抛出SecurityException 异常,如果该线程是活着的(alive)但是被挂起(suspend),它被恢复并继续它的执行进程。l 29. class A implements R

13、unnable int i; public void run() try Thread.sleep(5000); i=10; catch(InterruptException e) public static void main(String args) try A a=new A(); Thread t=new Thread(a); t.start(); 17) int j=a.i; 19) catch(Exception e) what be added at line line 17,ensure j=10 at line 19? A. a.wait(); B. t.wait(); C.

14、 t.join(); D.t.yield(); E.t.notify(); F. a.notify(); G.t.interrupt(); 答案:Cl 30. Given an ActionEvent, how to indentify the affected component? A.getTarget(); B.getClass(); C.getSource(); D.getActionCommand(); 答案:Dl 33. How to calculate cosine 42 degree? A.double d=Math.cos(42); B.double d=Math.cosin

15、e(42); C.double d=Math.cos(Math.toRadians(42); D.double d=Math.cos(Math.toDegrees(42); E.double d=Math.toRadious(42); 答案:Cl public class Test 2) public static void main(String args) 3) unsigned byte b=0; 4) b-; 5) 6) 7) what is the value of b at line 5? A.-1 B.255 C.127 D.compile fail E.compile succeeded but run error 答案:D

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号