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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

java面试题经典选择题部分.docx

1、java面试题经典选择题部分1 、给出如下代码 : class Test private int m; public static void fun() / some code. 如何使成员变量 m 被函数 fun() 直接访问 ? CA 、将 private int m 改为 protected int m B 、将 private int m 改为 public int m C 、将 private int m 改为 static int m D 、将 private int m 改为 int m 2 、下面哪个函数是 public void example(). 的重载函数? DA 、

2、private void example( int m). B 、 public int example(). C 、 public void example2(). D 、 public int example ( int m, float f). 3 、给出下面的代码段 : public class Base int w, x, y ,z; public Base(int a,int b) x=a; y=b; public Base(int a, int b, int c, int d) / assignment x=a, y=b w=d; z=c; 在代码说明 / assignment

3、x=a, y=b 处写入如下哪个代码是正确的? DA 、 Base(a,b); B 、 x=a, y=b; C 、 this(a),this(b); D 、 this(a,b); 4 、已知如下定义: String s = story; 下面哪个表达式是合法的? AA 、 s += books; B 、 char c = s1; C 、 int len = s.length; D 、 String t = 100; 5 、 Java 中 main() 函数的返回值是什么 ? DA 、 String B 、 int C 、 char D 、 void 6 、如下哪个字串在Java 中可作为自定义

4、标识符? AA 、 $number B 、 super C 、 3number D 、 #number 7 、如下哪个不是 Java 中有效的关键字? BA 、 const B 、 NULL C 、 false D 、 this 8 、如下哪个不是 Java 中正确的整数表示 ? DA 、 22 B 、 0x22 C 、 022 D 、 22H 9 、下面的代码段中,执行之后 i 和 j 的值是什么 ? Cint i = 1; int j; j = i+; A 、 1, 1 B 、 1, 2 C 、 2, 1 D 、 2, 2 10 、下面句话是正确的 ? AA 是算术右移操作符 . B 是算

5、术右移操作符 D 是算术右移操作符 11 、下面哪个赋值语句不是合法的? AA 、 float a = 2.0 B 、 double b = 2.0 C 、 int c = 2 D 、 long d = 2 12 、下面哪个是 main() 函数的合法参数 ? CA 、 char args B 、 char args C 、 String arg D 、 String args 13 、已知表达式 int m = 0, 1, 2, 3, 4, 5, 6 ; 下面哪个表达式的值与数组最大下标数相等? BA 、 m.length() B 、 m.length-1 C 、 m.length()+1

6、D 、 m.length+1 14.指出下列程序运行的结果(D) public class Example String str=new String(good); charch=a,b,c; public static void main(String args) Example ex=new Example(); ex.change(ex.str,ex,ch); System.out.print(ex.str+and); System.out.print(ex.ch); public void change(String str,char ch) str=test ok; ch0=g; A

7、.good and abc B.good and gbc C.test ok and abc D.test ok and gbc 15 .函数重载是指 ( A) A.两个或两个以上的函数取相同的函数名,但形参的个数或类型不同 B.两个以上的函数取相同的名字和具有相同的参数个数,但形参的类型可以不同 C.两个以上的函数名字不同,但形参的个数或类型相同 D.两个以上的函数取相同的函数名,并且函数的返回类型相同16.在异常处理中,如释放资源、关闭文件、关闭数据库等由( C)来完成。 A.try子句 B.catch子句 C.finally子句D.throw子句 17. 下面哪条语句定义了5个元素的数组

8、( A )A、int a=22,23,24,25,12;B、int a =new int(5);C、int 5 array;D、int arr;18 、已知如下的命令执行 java MyTest a b c 请问哪个语句是正确的? CA 、 args0 = MyTest a b c B 、 args0 = MyTest C 、 args0 = a D 、 args1= c 19. Applet类的直接父类是(D ) A.Component类 B.Container类 C.Frame类 D.Panel类 20.对于catch子句的排列,下列哪种是正确的( B ) A.父类在先,子类在后 B.子类

9、在先,父类在后 C.有继承关系的异常不能在同一个try程序段内 D.如何排列都可以 21. 下面哪个语句不能定义一个字符变量( B )A、char c1=a; B、char c2=” S ” ;C、char c4=97 ; D、char c3=u0041;22.构造方法何时被调用( B) A.类定义时B.创建对象时 C.调用对象方法时D.使用对象的变量时 23.下面的表达式中正确的是( AE) A.String s=你好;int i=3;s+=i; B.String s=你好;int i=3;if(i=s)s+=i; C.String s=你好;int i=3;s=i+s; D.String

10、s=你好;int i=3;s=i+; 24 、已知如下代码: public class Test long a = new long10; public static void main ( String arg ) System.out.println ( a6 ); 请问哪个情况是正确的? CA 、 输出为 null. B 、 输出为 0. C 、 编译时出错D 、 运行时出错25 、Frame的默认的布局管理器是下列哪一个( B) A.FlowLayoutB.BorderLayout C.GridLayoutD.CardLayout 26.下列语句片段 int a=10,b=4,c=20

11、,d=6; System.out.println(a+*b+c*-d); 的结果为( C) A.144B.28 C.140D.不能执行 27.下列语句片段: int a=-67,b=116,c=78; int d=ab&c; System.out.println(d)的结果为( A) A.70B.67 C.78D.56 28. 对象使用时,下面描述错误的是( B) A.通过“.”运算符调用成员变量和方法 B.通过成员变量的访问权限设定限制自身对这些变量方法的调用 C.将一个对象申明为类的成员时,必须在使用前为其分配内存 D.在方法中使用对象作为参数时,采用引用调用 29. 执行下列代码后,哪个

12、结论是正确的String s=new String10; BA.s10为B.s9为null C.s0为未定义 D.s.length为101 30. Java编程所必须的默认引用包为(B ) A.java.sys包B.java.lang包 C.java.new包 D.以上都不是 31.定义一个类名为“MyClass.java”的类,并且该类可被一个工程中的所有类访问,那么该类的正确声明应为:( C) A.private class MyClass extends Object B.class MyClass extends Object C.public class MyClass D.priv

13、ate class MyClass extends Object32 、以下哪个方法用于定义线程的执行体? CA 、 start() B 、 init() C 、 run() D 、 main() E 、 synchronized() 33 如果类中的成员变量可以被同一包访问,则使用如下哪个约束符 ? DA 、 private B 、 public C 、 protected D 、 缺省E 、 final 34 、以下哪个约束符可用于定义成员常量? BA 、 static B 、 final C 、 abstract D 、 finally35. 当方法遇到异常又不知如何处理时,下列哪种说法

14、是正确的(B ) A.捕获异常B.抛出异常 C.声明异常 D.嵌套异常 36. Java程序的执行过程中用到一套JDK工具,其中java.exe是指( C) A.Java文档生成器B.Java解释器 C.Java编译器D.Java类分解器 37.下列不属于容器的是(B ) A.WindowB.TextBox C.Panel D.ScrollPane38 、已知如下类说明: public class Test private float f = 1.0; int m = 12; static int n=1; public static void main(String arg) Test t

15、= new Test(); / some code. 如下哪个使用是正确的? DA 、 t.f B 、 this.n C 、 Test.m D 、 Test.n 39 、已知如下代码: 1: class Example 2: String str; 3: public Example() 4: str= example; 5: 6: public Example(String s) 7: str=s; 8: 9: 10: class Demo extends Example 11: 12: public class Test 13:public void f () 14:Example ex

16、= new Example(Good); 15:Demo d = new Demo(Good); 16: 哪句语句会导致错误? EA 、 line 3 B 、 line 6 C 、 line 10 D 、 line 14 E 、 line 15 40 、已知如下类定义: class Base public Base () /. public Base ( int m ) /. public void fun( int n ) /. public class Child extends Base / member methods 如下哪句可以正确地加入子类中? DA 、 private void

17、 fun( int n ) /. B 、 void fun ( int n ) /. C 、 protected void fun ( int n ) /. D 、 public void fun ( int n ) /. 41 在如下源代码文件 Test.java 中 , 哪个是正确的类定义? BA 、 public class test public int x = 0; public test(int x) this.x = x; B 、 public class Test public int x=0; public Test(int x) this.x = x; C 、 public

18、 class Test extends T1, T2 public int x = 0; public Test (int x) this.x = x; D、 protected class Test extends T2 public int x=0; public Test(int x) this.x=x; 42、当 Frame 改变大小时,放在其中的按钮大小不变,则使用如下哪个 layout? AA 、 FlowLayout B 、 CardLayout C 、 BorderLayout D 、 GridLayout 43 、如下哪个方法可以从 WindowEvent 获取事件源 ? C

19、A 、 getFrame() B 、 getID() C 、 getSource() D 、 getEvent() 44监听器接口的方法返回值是什么? CA 、 int B 、 String C 、 void D 、 Object 45下面哪个方法与 applet 的显示无关 ? BA 、 update() B 、 draw() C 、 repaint() D 、 paint() 46下面哪个不是 Java 中的容器 ? BA 、 ScrollPane B 、 Canvas C 、 Dialog D 、 Applet 47在Java中,属于整数类型变量的是( C) A.single B.dou

20、ble C.byte D.char48下面哪个描述是正确的( C )A、Applet程序中不需要main()方法,也不能有B、Application程序中可以没有main()方法。C、Applet程序中可以不定义init( )方法D、Application程序中必须有run( )方法 49 给出一段程序,试判断哪个是正确的结果( B )public class rtExcept public static void throwit()System.out.print(“throwit”); throw new RuntimeException(); public static void mai

21、n(String aa) try System.out.print(“hello “); throwit(); catch(Exception re) System.out.print(“caught ”); finally System.out.print(“finally ”); System.out.print(“after ”); A、hello throwit caughtB、hello throwit caught finally after C、hello throwit RuntimeException afterD、hello throwit caught finally a

22、fter RuntimeException50. 下列哪个方法可用于创建一个可运行的类( A) A.public class X implements Runable public void run(). B.public class X implements Thread public void run(). C.public class X implements Thread public int run(). D.public class X implements Runable protected void run(). 1.Which statement is true? A.An

23、anonymous inner class may be declared as final. B.An anonymous inner class can be declared as private. C.An anonymous inner class can implement multiple interfaces . D.An anonymous inner class can access final variables in any enclosing scope. E.Construction of an instance of a static inner class re

24、quires an instance of the enclosing outer class.答案是D anonymous inner class can not declared with any modifyer. and can only implement one interface2. Which statement about static inner classes is true? A.An anonymous class can be declared as static B.A static inner class cannot be a static member of

25、 the outer class C.A static inner class does not require an instance of the enclosing class D.Instance members of a static inner class can be referenced using the class name of the static inner class 答案是Cbecause static , it neednt instance of enclosing outer class and its instance member need its in

26、stance.3.public class Foo public static void main(String sgf) StringBuffer a = new StringBuffer(A); StringBuffer b = new StringBuffer(B); operate(a,b); System.out.println(a+,+b); static void operate(StringBuffer x,StringBuffer y) x.append(y); y=x; What is the result? A.The code compiles and prints “

27、A.B”. B.The code compiles and prints “A.A”. C.The code compiles and prints “B.B”. D.The code compiles and prints “AB.B”. E.The code compiles and prints “AB.AB”. 答案是Djava中都是按值传递的,所以a,b还是指向原来的地址空间,经过operate操作后,x更改了该地址空间的值,而y没有.public class Foo public static void main(String sgf) StringBuffer a = new S

28、tringBuffer(A); StringBuffer b = new StringBuffer(B); operate(a,b); /方法调用完以后,a对象的内容为:AB,b对象的内容为:B System.out.println(a+,+b); static void operate(StringBuffer x,StringBuffer y) /对象传递进来以后又分别复制了一个x和y对象x和y, x和x指向同一个对象。y和y指向同一个对象。 x.append(y); /所以执行此步操作以后,main中的x对象的内容也变化了。 /因为本来就是指向同一个对象吗! y=x; /执行此步操作以后,main中的y对象的内容没变! /因为此y费彼y也! class ValHold public int i = 10; public class ObParm public static void main(String argv) ObParm o = new ObParm(); o.amethod(); p

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

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