java语言试题-样题2017_第1页
java语言试题-样题2017_第2页
java语言试题-样题2017_第3页
java语言试题-样题2017_第4页
java语言试题-样题2017_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1 JAVA 程序设计程序设计 2017 年年 样题样题 一 一 单项单项选择题选择题 1 属于合法的 Java 标识符 A tom123 B 5books C static D 3 14159 2 下面对数组数组的声明和初始化正确的是 A int arr B int arr 5 C int arr 2 1 2 3 D int arr 1 2 3 4 5 3 下面语句中 会出现编译错误错误 A float a 5 6 B double d 5 6 C int c 2 D long s 2 4 以下代码段执行后的输出结果为 int x 3 int y 10 System out println y x A 2 0 B 1 C 3 33333 D 3 5 Java 语言中 是 JFrame 的默认布局管理器 A BorderLayout B FlowLayout C GridLayout D CardLayout 6 如果一个线程调用了方法 sleep 则类 java lang Thread 的下列 方法可以唤醒该线程 A notify B resume C run D start 7 下列说法中不不正确的一项是 A 多线程并发执行时 各个线程中语句的执行顺序是确定的 B 多线程并发执行时 线程之间的相对执行顺序是确定的 C 线程执行顺序的不确定性会导致执行结果的不确定性 D 线程执行顺序的不确定性会破坏共享数据的一致性 8 进行 JDBC 编程时 用来加载数据库驱动程序的方法是 A Class forName B class ForName C executeQuery D creatStatement 9 下列不能激活 ActionEvent 事件动作是 A 单击按钮 B 最小化窗口 C 选择列表框 D 选择菜单项 2 10 不属于容器的构件 A JFrame B JLabel C JDialog D JPanel 11 以下哪个关键字可以用来为对象加互斥锁 A transient B static C serialize D synchronized 12 Java语言使用的字符码集是 A Unicode B BCD C DCB D ASC 13 下面的代码段执行之后 sum 的值是什么 int sum 1 for int i 1 i 5 i sum i System out println sum A 5 B 1 C 15 D 16 14 声明并创建一个按钮对象 b 应该使用的语句是 A Button b new Button B button b new button C Button b new b D b setLabel 确定 15 下面哪一个 import 命令可以为我们提供编写网络应用程序的类 A import java sql B import java util C import java io D import 16 要给类 AB 的一个无参数返回值的方法 method 书写方法头 使得使用类名 AB 作为前缀就可 以调用它 即调用形式为 AB method 那么该方法头的定义形式是 A static void method B public void method C final void method D abstract void method 17 有下面的类定义 与 setVar 方法不能重载的方法是 Public class MyClass Public void setVar int a int b float c A private void setVar int a float b int c B protected void setVar int x int y float z C public int setVar int a float c int b return a D public int setVar int a float c return a 18 以下声明合法的是 A String s B public final static void int w C double abstract d D abstract final double hyperbolicCosine 19 MyClass 定义了 methodA 方法 该方法的返回值应是 3 Public class MyClass method byte x double y return short x y 2 A short B double C char D int 20 已知如下定义 String s story 下面哪个语句不不是合法的 A s books B s s 100 C int len s length D String t s abc 21 类 Test1 Test2 定义如下 1 public class Test1 2 public float aMethod float a float b throws 3 IOException 4 5 public class Test2 extends Test1 6 7 将以下哪种方法插入行 6 是不合法的 A float aMethod float a float b B public int aMethod int a int b throws Exception C public float aMethod float p float q D public int aMethod int a int b throws IOException 22 若在某一个类定义中定义有如下的方法 abstract void performDial 该方法属于 A 接口方法 B 最终方法 C 抽象方法 D 空方法 23 若已定义 int a 0 1 2 3 4 5 6 7 8 9 则对 a 数组元素正确的引用是 A a 1 B a 9 C a 10 D a 0 24 以下关于 Java 语言继承的说法正确的是 A Java 中的类可以有多个直接父类 B 抽象类不能有子类 C Java 中的接口支持多继承 D 最终类可以作为其它类的父类 25 下列关于 Java 程序结构的描述中 不正确的一项是 A 一个 Java 源文件中可以包括多个类定义 但是只能有一个 public 类 B 一个 Java 源文件中可以包括一个 package 语句 C 一个 Java 源文件中可以有多个 public 类 D 源文件名与程序类名必须一致 二 不定项选择题 4 26 Plant 类派生出子类 Flower Flower 类派生出子类 Rose 以下声明正确的是 A Plant p new Plant B Plant a1 new Flower C Flower f new Rose D Rose r new Plant 27 下面程序编译运行后输出的结果是 public class abc String s1 java public static void main String args int z 2 abc t new abc System out println t s1 z A java2 B 2 C 程序有编译错误 D java E 没有任何输出 28 给出下面代码 public class abc String str new String good char ch a b c public static void main String args abc ex new abc 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 ch 0 g 程序执行结果是 A good and abc B good and gbc C test ok and abc D test ok and gbc 29 下面程序有 4 条语句前编了行号 有错误语句的行号是 public class test1 public static void main String argc unsigned byte b 0 b b 1 System out println b 5 A B C D 30 有下程序 import java io IOException public class t1 public static void methodA throws IOException try throw new IOException file not found catch IOException e System out println I cannot find the file throw e public static void main String args try methodA catch IOException e System out println Caught Exception 该程序的输出结果为 A 程序有错 代码不能被编译 B I cannot find the file Caught Exception C file not found Caught Exception D Caught Exception E file not found I cannot find the file 三三 填空题 填空题 31 顺序执行以下两个语句的输出结果是 String s 程序设计语言 System out println s length 32 在 Java 中只能实现单继承 Java 不支持多重继承 但可通过 实现多重继承 33 在 Java 中若定义抽象类则需要加关键字 来修饰 34 Java 中 如果在子类中想使用被子类隐藏了的父类的成员变量或方法 就可以使用关键 字 35 数组 x 定义如下 int x new int 10 则 x length 的值为 36 Java 的类的变量定义中 用关键字 修饰的变量是类变量 或叫静态变量 37 设有数组定义 int MyIntArray 1 2 3 4 5 6 7 8 9 10 则执行以下几个语句后的输 出结果是 6 int s 0 for int i 0 i 7 i s MyIntArray i System out println s 38 布尔型 boolean 数据只有 true 和 两个值 39 创建类的对象时 使用运算符 给对象分配内存空间 40 接口中的成员只有静态常量和 四四 读程序写结果 读程序写结果 41 写出程序的运行结果 public class abc public static void main String args AB s new AB Hello I love JAVA System out println s class AB String s1 String s2 public AB String str1 String str2 s1 str1 s2 str2 public String toString return s2 public String toShow return s1 public String toPrint return s1 s2 程序输出的结果是 42 写出下面程序的运行结果 class A double f int x int y return x y class B extends A double f double x double y 7 return x y public class te public static void main String args B b new B System out println b f 3 5 System out println b f 3 0 5 0 程序的运行结果是 43 写出下面程序的运行结果 class Father public Father System out println father without parameter public Father String s System out println father with parameter is s class Child extends Father public Child System out println child without parameter public Child String s System out println child with parameter is s public class Confunction public static void main String args Child c new Child Child c1 new Child ok 程序的运行结果是 44 写出下面程序的运行结果 abstract class Shape 定义抽象类Shape和抽象方法display abstract void display 8 class Circle extends Shape void display System out println Circle class Rectangle extends Shape void display System out prin

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论