java课堂练习题(编辑修改稿)内容摘要:

象 既能作为类的修饰符 , 也能作为类成员的修饰符的是 ( ) A、 public B、 extends C、 Float D、 static 答案: A 下列选项中,用于定义接口的关键字是 ( ) A、 import B、 implements C、 interface D、 protected 答案: C 定义类头时能使用的修饰符是 ( )。 A) private B) static C) abstract D) protected 答案: C 定义类的的修饰符可以是抽象的,共有的或者是省略。 下列类定义中,不正确的是 ( )。 A) class x { .... } B) class x extends y { .... } C) static class x implements y1,y2 { .... } D) public class x extends Applet { .... } 答案: C Java 语言的类间的继承关系是 ( )。 A) 多重的 B) 单重的 C) 线程的 D) 不能继承 答案: B 下列选项中,用于在定义子类时声明父类名的关键字是 ( )。 A) interface B) package C) extends D) class 答案: C 定义类头时能使用的修饰符是 ( )。 A) private B) static C) abstract D) protected 答案: C 定义抽象类 下列最终属性 i 的定义中,正确的是 ( )。 A) static final int i=100。 B) final int i=。 C) final i=39。 w39。 D) final char i。 答案: A 固定用法 下列类定义中,不正确的是 ( )。 A) class x { .... } B) class x extends y { .... } C) static class x implements y1,y2 { .... } D) public class x extends Applet { .... } 答案: C 静态类不能实现接口 设 x、 y 为已定义的类名,下列声明 x类的对象 x1 的语句中正确的是 ( )。 A) static x x1。 B) public x x1=new x(int 123)。 C) y x1。 D) x x1=x( )。 1 下列方法定义中,正确的是 ( )。 A) int x( ){ char ch=39。 a39。 return (int)ch。 } B) void x( ){ ...return true。 } C) int x( ){ ...return true。 } D) int x( int a, b){ return a+b。 } 答案: A 1 用于定义类成员的访问控制权的一组关键字是 ( )。 A) class, float, double, public B) float, boolean, int, long C) char, extends, float, double D) public, private, protected 答案: D 答案: A 静态类对象的声明 1 设 i、 j、 k 为类 x 中定义的 int 型变量名,下列类 x 的构造函数中 不正确的是 ( )。 A) x( int m){ ... } B) void x( int m){ ... } C) x( int m, int n){ ... } D) x( int h,int m,int n){ ... } 答案: B 1 下面数据结构中,属于非线性的是 ( )。 A) 线性表 B) 树 C) 队列 D) 堆栈 答案: B 多项 下面的表达式哪个是正确的 ?( ) 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 s=你好。 int i=3。 s=i+。 //非法表达式 E、 String s=null。 int i=(s!=null)amp。 amp。 (0)?():0。 //()。 答案: A 和 C 定义一个类名为 的类,并且该类可被一个工程中的所有类访问,那么该类的正确声明应为: ( ) A、 private class MyClass extends Object B、 class MyClass extends Object C、 public class MyClass D、 public class MyClass extends Object 答案: C 和 D 指出下列哪个方法与方法 public void add(int a){}为合理的重载方法。 ( ) A、 public int add(int a) B、 public void add(long a) C、 public void add(int a,int b) D、 public void add(float a) 答案: BCD 有的认为是 CD 如果下列的方法能够正常运行,在控制台上将显示什么 ?( ) public void example(){ try{ unsafe()。 (Test1)。 }catch(SafeException e){ (Test 2)。 } finally{(Test 3)。 } (Test 4)。 } A、 Test 1 B、 Test 2 C、 Test 3 D、 Test 4 答案: ACD 给定下面的代码片段: public void Test() { try { method()。 (Hello World)。 } catch (ArrayIndexOutOfBoundsException e) { (Exception?)。 } catch(Exception e) { (Exception1)。 } finally{ (Thank you!)。 } } 如果函数 method 正常运行并返回,会显示下面的哪些信息 ? ( ) A、 Hello World B、 Exception C、 Exception1 D、 Thank you! 答案: A 和 D 下面的说法正确的是: ( ) A、 Java 语言里的线程不是对象 //线程也是对象 B、 Applet 不需要 main 方法 C、 Java 语言的对象都是 的子类 D、 double 是 Java 语言的合法标识符 //double 是关键字 答案: B 和 C 下面的 Java 语句错误的是: ( ) A、 Double a=。 //Double 应该小写 B、 double a=。 C、 (hello)。 //(“”)。 D、 DatagramSocket a = new DatagramSocket() 有关 Applet 小应用程序和图形用户界面 GUI 的题 欲编写如下图的一个界面,用于显示用户指定的图像 : 如果在区域 A 中只能放置一个 AWT 组件,从各组件的本来功能角度考虑,最好使用哪种组件: ( ) A、 TextArea B、 Panel C、 Applet D、 Canvas 答案: D 界面如上题所示。 若 Button1的功能是:点击后弹出一个用于输入的界面,获取用户想要显示的图像文件名,则该界面最好是(从编程简单和程序不易出错的角度考虑) :( ) A、 模式( Modal) Dialog B、 非模式( Nonemodal) Dialog C、 FileDialog D、 Frame 答案: C 界面如上题所示。 如果在 A 区域使用某种 AWT 组件( 的子类)来负责绘制图像 ,则绘图的语句最好应 放在该组件的哪个方法中 (考虑到应用程序和 Java 虚拟机的 AWT 线程都会要求重画该组件 )。 ( ) A、 构造方法 B、 paint( Graphics g) C、 update( Graphics g) D、 repaint() 答案: B 下面关于 Applet 的说法正确的是 ( ) A、 Applet 也需要 main 方法 B、 Applet 必须继承自 C、 Applet 能访问本地文件 D、 Applet 程序不需要编译 答案: B 指出下列程序运行 的结果 ( ) public class Example{ String str=new String(good)。 char[]ch={39。 a39。 ,39。 b39。 ,39。 c39。 }。 public static void main(String args[]){ Example ex=new Example()。 (,)。 (+ and )。 ()。 } public void change(String str,char ch[]){ str=test ok。 ch[0]=39。 g39。 } } A、 good and abc B、 good and gbc C、 test ok and abc D、 test ok and gbc 答案: B 运行下列程序 , 会产生什么结果 ( ) public class X extends Thread implements Runable{ public void run(){ (this is run())。 } public static void main(String args[]){ Thread t=new Thread(new X())。 ()。 } } A、 第一行会产生编译错误 B、 第六行会产生编译错误 C、 第六行会产生运行错误 D、 程序会运行和启动 答案: A 要从文件 “ ” 文件中读出第 10个字节到变量 C中 , 下列哪个方法适合 ?( ) A、 FileInputStream in=new FileInputStream()。 (9)。 int c=()。 B、 FileInputStream in=new Fil。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。