ImageVerifierCode 换一换
格式:DOCX , 页数:15 ,大小:18.83KB ,
资源ID:10269432      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/10269432.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Java基础面试题范本模板.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Java基础面试题范本模板.docx

1、Java基础面试题范本模板1.下面能够得到文件“file。txt”的父路径的是:A.String name= File。getParentName(“file.txt); B.String name= (new File(“file。txt”))。getParent();C.String name = (new File(“file.txt”).getParentName();D.String name= (new File(“file.txt”).getParentFile(); 2.在Java中,要创建一个新目录,要使用的类的实例是:A。FileB.FileOutputStreanC.Pr

2、intWriterD。Dir3。题目代码的功能为:在d:创建一个文件“test。txt”,并向文件写入“HelloWorld”,然后删除文件. public static void main(String args) File file = new File(d:”, file。txt”); try catch (Exception e) e。printStackTrace(); A。 BufferedWriter bw = new BufferedWriter(new FileWriter(file); bw.write(”HelloWorld); bw.close(); if (file.

3、exists()) file。delete(); B。 BufferedWriter bw = new BufferedWriter(new FileWriter(file)); bw.write(”HelloWorld); bw.close(); if (file.exists() file.deleteFile(); C。BufferedWriter bw = new BufferedWriter(file); bw。write(”HelloWorld); bw.close(); if (file.exists()) file.delete(); D. BufferedWriter bw

4、= new BufferedWriter(file); bw.write(”HelloWorld”); bw.close(); if (file.exists()) file。deleteFile(); 4。题目代码功能为:打印扩展名为txt的文件public static void main(String args) String dir=d:/javalesson”; File currDir=new File(dir); FilenameFilter filter=new JavaFilter(); String javaFiles=currDir.list(filter); for(i

5、nt i=0;ijavaFiles。length;i+) System.out。println(javaFilesi); 代码中JavaFilter类的代码为:A。public class JavaFilter implements FilenameFilter public void accept(File dir, String name) return name。endsWith(”。txt”); B.public class JavaFilter implements FilenameFilter public boolean accept(File dir, String name)

6、 return name.endsWith(.txt”); C.public class JavaFilter extends FilenameFilter public boolean accept(File dir, String name) return name.endsWith(”。txt); D. public class JavaFilter extends FilenameFilter public void accept(File dir, String name) return name.endsWith(”。txt”); 5. 下列关于序列化和反序列化描述正确的是A。序列

7、化是将数据转换为 n个byte序列的过程B.反序列化是将n个 byte 转换为一个数据的过程C。将类型int 转换为4 byte是反序列化过程D。将8个字节转换为long类型的数据是序列化过程6。请看下列代码:interface Foo class Alpha implements Foo class Beta extends Alpha public class Delta extends Beta public static void main(String args) Beta x = new Beta(); 插入代码 在插入代码处,填入下列代码,运行时能引起java.lang。Clas

8、sCastException异常的是:A。 Alpha a = x;B. Foo f= (Delta)x;C。 Foo f= (Alpha)x;D. Beta b = (Beta)(Alpha)x;7.请看下列代码:1:public class Foo 2: public static void main(String args) 3: try 4: A a = new A();5: a.method1();6: catch (Exception e) 7: System.out。print(an error occurred”);8: 9: 10:1:class A 2: public vo

9、id method1() 3: B b = new B();4: b。method2();5: System。out。println(”method one);6: 7:1:class B 2: public void method2() 3: C c = new C();4: c。method3();5: System.out.println(”method two”);6: 7:1:class C 2: public void method3() 3: System。out。println(”method three);4: throw new NullPointerException()

10、;5: 6:关于上述代码说法正确的是:A.Foo类的第7行将被执行B。A类的第5行将被执行C。B类的第5行将被执行D。C类的第3行将被执行8.请看下列代码:public class A public String sayHello(String name) throws TestException if (name = null) throw new TestException(); return ”Hello + name; public static void main(String args) throws TestException A a=new A(); System。out.pr

11、intln(a。sayHello(null); class TestException extends Exception 关于上述代码说法正确的是:A。A类编译失败B.代码”System.out。println(a.sayHello(John”));行,会抛出未检查异常TestExceptionC.代码” A a=new A();”行,会抛出未检查异常TestExceptionD。代码”System.out.println(a.sayHello(John”));”行,会抛出已检查异常TestException9.请看下列代码:1。 / some code here2。 try 3. / so

12、me code here4. catch (SomeException se) 5. / some code here6。 finally 7. / some code here8. 下面哪三种情况能使第7行的代码执行:A.第3行抛出异常B.第1行抛出异常C。第5行抛出异常D。第3行代码成功执行10.以下说法错误的是:A.try catch 。 catch,多个catch时,后一个catch捕获类型一定是前一个的父类B。try。finally 可以组合使用C。throw抛出一些异常,程序不进行处理,程序编译也无错误D.throws 一定是写在方法后面11。下列代码运行的结果是:public c

13、lass A public void process() System。out。print(A ); public static void main(String args) try (A) new B())。process(); catch (Exception e) System.out.print(”Exception”); class B extends A public void process() throws RuntimeException super。process(); if (true) throw new RuntimeException(); System.out.p

14、rint(B ); A.ExceptionB。A ExceptionC。A Exception BD。A B Exception12。下列代码实现的功能是: FileOutputStream fos = new FileOutputStream(”system。txt,true); PrintStream ps = new PrintStream(fos); System。setOut(ps);System.out。println(writer); A。向控制台打印“writer,可以实现追加打印B。向控制台打印“writer,但是不可以实现追加打印C.向文件system.txt写“write

15、r”,但是不可以实现追加写D。向文件system。txt写“writer”,可以实现追加写13。在Java中,下面的代码会出现编译错误的是:A.File f = new File(”/,autoexec.bat);B.DataInputStream din = new DataInputStream(new FileInputStream(”autoexec。bat”);C。InputStreamReader in = new InputStreamReader(System.in);D.OutputStreamWriter out = new OutputStreamWriter(Syste

16、m.in); 14。java.io。BufferedWriter 和java。io.FileWriter相比, java.io.FileWriter没有但是java.io。BufferedWriter有的方法是:A。关闭流的方法B.刷新流的缓冲的方法C。写入流的方法D.写入一个行分隔符15。 给定一个Java程序的main方法的代码片段如下:假如d 盘下不存在abc。txt文件,现运行该程序,下面说法正确的是( )try PrintWriter out=new PrintWriter(new FileOutputStream(“d:/abc.txt”)) ; String name=”tare

17、na; out。print(name) ; out。close( ) ;catch(Execption e) System.out。println(“文件没有发现!“) ;A。将在控制台上打印:“文件没有发现!B。正常运行,但没有生成文件abc.txtC。运行后生成abc。txt ,但该文件中无内容D.运行后生成abc.txt,该文件内容为:tarena16. 关于java.io。Serializable接口说法正确的是:A。java.io。Serializable中有一个serialID属性,但是没有方法B.类通过实现java.io.Serializable 接口以启用其序列化功能C。jav

18、a.io.Serializable中有一个run方法,但是没属性D.java。io.Serializable接口没有方法或属性,仅用于标识可序列化的语义。17。关于线程的设计,下列描述正确的是:A。线程对象必须实现Runnable接口B.启动一个线程直接调用线程对象的run()方法C。Java提供对多线程同步提供语言级的支持D. 一个线程可以包含多个进程18。下列代码编译和运行的结果是: public static void main(String args) Runnable r = new Runnable() public void run() System。out.print(”Cat

19、”); ; Thread t = new Thread(r) public void run() System.out.print(Dog”); ; t。start(); A.CatB.DogC.运行无输出D。编译失败19。下面能使线程处于阻塞状态的是:A.sleep();B。notify();C。synchronized(Object obj)D.wait();20。下列代码编译和运行的结果是:public class TestOne public static void main(String args) throws Exception Thread.sleep(3000); Syste

20、m.out。println(”sleep”); A.编译错误B。抛出运行时异常C。输出:sleepD.代码正常运行,但是无输出21.现有一个线程dt,把dt线程设置为守护线程的方式正确的是:A。Thread.setDaemon(true);B.dt。daemon(true);C.Thread.daemon(true);D.dt。setDaemon(true);22.请看下列代码:class ThreadDemo implements Runnable int age=0; public synchronized void run() for(int i=0;i100;i+) System。ou

21、t.println(”age=”+(age+)); 下列构造线程对象的方式中,两个线程共用一个age数据的是:A。ThreadDemo r1=new ThreadDemo();ThreadDemo r2=new ThreadDemo();B。Thread t1=new Thread();Thread t2=new Thread();C。ThreadDemo r1=new ThreadDemo();Thread t1=new Thread(r1);Thread t2=new Thread(r1);D.ThreadDemo r1=new ThreadDemo();ThreadDemo r2=new

22、 ThreadDemo();Thread t1=new Thread(r1);Thread t2=new Thread(r2);23.可以对对象加互斥锁的关键字是:A.transient B。synchronized C.serialize D.static24.下列属于线程安全的类的是A.AarryListB.VectorC.HashMapD。Hashtable25。下面关于ServerSocket描述正确的是:A.ServerSocket类实现服务器套接字B。ServerSocket类的accept()方法侦听并接受到客户端套接字C。一个服务器端只能有一个客户端进行连接D。一个服务器端可以有多个客户端进行连接

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1