已阅读5页,还剩8页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1 Java 中对数据库查询结果集进行操作的对象是中对数据库查询结果集进行操作的对象是 D A Connection 对象对象 B Statement 对象对象 C DriverManager 对象对象 D ResultSet 对象对象 2按运算符操作数的数目划分 运算符 的类 型是 A A 三目 B 双目 C 四目 D 单目 3 有关在有关在 Java 中定义实例方法和类方法的叙述正中定义实例方法和类方法的叙述正 确的是 确的是 D A 前者有 前者有 public 修饰 后者没有修饰 后者没有 public 修饰修饰 B 前者没有 前者没有 public 修饰 后者有修饰 后者有 public 修饰修饰 C 前者有 前者有 static 修饰 后者没有修饰 后者没有 static 修饰修饰 D 前者没有 前者没有 static 修饰 后者有修饰 后者有 static 修饰修饰 4 Java 代码 g drawLine 100 100 100 100 的功 能是 B A 画一个圆 B 画一条线段 C 画一个点 D 代码是错误的 5有有 Java 语句如下 则说法正确的是 语句如下 则说法正确的是 C int a b new int 3 1分分 A 此语句是错误的 此语句是错误的 B a length 的值为的值为3 C b length 的值为的值为3 D a length 和和 b length 的值都为的值都为3 6 以下程序代码的输出结果是 以下程序代码的输出结果是 B System out println 100 8 1分分 A 12 5 B 12 C 4 D 0 7 在 Java 语言中 一般不作为容器使用的是 A JDialog B JFrame C JTextArea D JPanel 8 在 Java 语言中 把按钮 button 的标题文字设 置为 第一个按钮 的方法是 A A button SetText 第一个按钮 B button GetText 第一个按钮 C button SetLabel 第一个按钮 D button GetLabel 第一个按钮 9 在 在 Java 程序中声明一个数组 错误的是 程序中声明一个数组 错误的是 C A int a B int a C float a 10 D float a 10 在 在 Java 程序中有定义 程序中有定义 int x new int 4 5 则则 x length 和和 x 3 length 的值分别的值分别 是 是 A A 4和和5 B 5和和4 C 4和和3 D 5和和3 11 定义一个使用接口 Java lang Runnable 的类 必须要实现的方法是 1分 B A start B run C init D paint 12 如果发生多个线程形成一个等待环 这样 所有线程都陷入相互等待的状态 这种循环等待现象称 为 1分 A 互斥 B 同步 C 死锁 D 临界 13 下列关于线程的说法正确的是 下列关于线程的说法正确的是 A 一个线程被创建 它就立即开始运行 一个线程被创建 它就立即开始运行 B 使用 使用 start 方法可以使一个线程立即开始运方法可以使一个线程立即开始运 行行 C 当一个线程因为抢先机制而停止运行时 它被 当一个线程因为抢先机制而停止运行时 它被 放在可运行队列的前面放在可运行队列的前面 D 一个正在运行的线程可能因为某些情况而进入 一个正在运行的线程可能因为某些情况而进入 阻塞状态阻塞状态 14 在 Java 程序中有代码如下 System out println new StringTokenizer I am a student a countTokens 则输出结果为 1分 c A I am a student B 2 C 3 D 4 15 定义一个使用接口 定义一个使用接口 Java lang Runnable 的的 类 必须要实现的方法是 类 必须要实现的方法是 A start B run C init D paint 16 下列关于继承的哪项叙述是正确的 下列关于继承的哪项叙述是正确的 A 在 在 java 中允许多重继承中允许多重继承 B 在 在 java 中一个类只能实现一个接口中一个类只能实现一个接口 C 在 在 java 中一个类不能同时继承一个类和实现中一个类不能同时继承一个类和实现 一个接口一个接口 D java 的单一继承使代码更可靠的单一继承使代码更可靠 17 下列关于线程优先级的说法中 正确的是 下列关于线程优先级的说法中 正确的是 A 线程的优先级是不能改变的 线程的优先级是不能改变的 B 线程的优先级是在创建线程时设置的 线程的优先级是在创建线程时设置的 C 在创建线程后的任何时候都可以设置 在创建线程后的任何时候都可以设置 D B 和和 C 18 对于构造函数 下列叙述正确的是 对于构造函数 下列叙述正确的是 A 构造函数不允许重载 构造函数不允许重载 B 构造函数没有返回类型 构造函数没有返回类型 C 子类不允许调用父类的构造函数 子类不允许调用父类的构造函数 D 在同一个类中定义的重载构造函数不可以相互 在同一个类中定义的重载构造函数不可以相互 调用调用 19 JAVA 中为字符型输入中为字符型输入 输出流提供的读字输出流提供的读字 符的方法所使用的类是符的方法所使用的类是 C A InputStream B OutputStream C FIleReader D FileWriter 20 以下程序代码的输出结果是 以下程序代码的输出结果是 D int x 100 System out println 5 5 x 8 1分分 A 5 512 B 5 512 5 C 18 D 5 54 21 下列哪些字符串匹配模式 boy w 3 A boy111 B boy C boyweo D boyboyboyboy 22 下列哪个关键可用来定义 Java 常量 A public B static C final D void 23 在 在 Java 程序中有代码如下 程序中有代码如下 System out println new StringTokenizer I am a student a countTokens 则输出结果为 则输出结果为 1分分 C A I am a student B 2 C 3 D 4 24 为 为8位字节流数据提供读操作支持的类是 位字节流数据提供读操作支持的类是 1分分 A FileInputStream B FileOutputStrem C FileReader D FileWriter 25 下列有关抽象类及抽象方法的叙述错误的是 下列有关抽象类及抽象方法的叙述错误的是 1分分 A 使用 使用 final 修饰的类是抽象类修饰的类是抽象类 B 使用 使用 abstract 修饰的方法是抽象方法修饰的方法是抽象方法 C 抽象类必须被继承才能使用 抽象类不可能有 抽象类必须被继承才能使用 抽象类不可能有 实例实例 D 抽象类可以没有抽象方法 但有抽象方法的类 抽象类可以没有抽象方法 但有抽象方法的类 一定是抽象类一定是抽象类 26 Java 中对数据库查询结果集进行操作的对象中对数据库查询结果集进行操作的对象 是 是 A Connection B Statement C DriverManager D ResultSet 27 在 在 Java 中 一个类可同时定义许多同名的方中 一个类可同时定义许多同名的方 法 这些方法的形式参数的个数 类型或顺序各不相同 法 这些方法的形式参数的个数 类型或顺序各不相同 传回的值也可以不相同 传回的值也可以不相同 这种面向对象程序特性称为 这种面向对象程序特性称为 A 隐藏 隐藏 B 覆盖 覆盖 C 重载 重载 D Java 不支不支 持此特性持此特性 28 若在某一个类定义中定义有如下的方法 若在某一个类定义中定义有如下的方法 abstract void performdial 该方法属于 该方法属于 A 本地方法 本地方法 B 抽象方法 抽象方法 C 解态方法 解态方法 D 最终方法 最终方法 29 J2SE 是是 A Java 企业平台企业平台 B Java 标准平台标准平台 C Java 小型平台小型平台 D Java 小型平台第二版小型平台第二版 31 下列哪种操作不会跑出异常 下列哪种操作不会跑出异常 A A 浮点数除以浮点数除以0得到得到 InfinityB i 0 0 C 打开不存在的文件打开不存在的文件 D a 1 100 32 于 于 length 表述正确的是 表述正确的是 C A 数组有数组有 length 方法 方法 String 也有也有 length 方法 方法 A 数组有数组有 length 方法 方法 String 没有没有 length 方法 方法 A 数组没有数组没有 length 方法 方法 String 有有 length 方法 方法 A 数组没有数组没有 length 方法 方法 String 也没有也没有 length 方法 方法 33 在 在 Java 程序中有定义 程序中有定义 int x new int 4 5 则则 x length 和和 x 3 length 的值分别是 的值分别是 A 4和和5 B 5和和4 C 4和和3 D 5和和3 34 下列程序的输出结果是 下列程序的输出结果是 StringBuffer buf1 new StringBuffer 20 buf1 append student System out println buf1 length buf1 capacity A 20 20 B 7 20 C 0 20 D 0 0 35 当使用 当使用 FileInputStream 类中的类中的 read 方方 法时 如果没有读入一个字节数据时 返回值为 法时 如果没有读入一个字节数据时 返回值为 A 0 B 1 C true D false 36 下列程序的输入结果是 StringBuffer buf1 new StringBuffer 20 buf1 append student System out println buf1 length buf1 capacity A 20 20 B 7 20 C 0 20 D 0 0 39 一个实现 一个实现 Runnabel 接口的类必须要实现的接口的类必须要实现的 方法是 方法是 A start B run C sleep D init 40 下列有关 下列有关 Java 的叙述错误的是 的叙述错误的是 1分分 D A 强类型语言 强类型语言 B 与平台无关 与平台无关 C 可以使用汉字变量名 可以使用汉字变量名 D 不检查数组下标越界 不检查数组下标越界 41下列有关数组的叙述错误的是 下列有关数组的叙述错误的是 1分分 D A 数组是将一组相同类型的数据顺序存储 组成 数组是将一组相同类型的数据顺序存储 组成 一种复合数据类型一种复合数据类型 B 在 在 Java 语言中 数组是一种引用类型 数组语言中 数组是一种引用类型 数组 名如同对象名一样 是一种引用名如同对象名一样 是一种引用 C 对于多维数组 从最高维开始 可以对每一维 对于多维数组 从最高维开始 可以对每一维 分配不等长的空间分配不等长的空间 D 在 在 Java 语言中 数组元素可以互相赋值 而语言中 数组元素可以互相赋值 而 数组名不能直接赋值数组名不能直接赋值 42 当线程当线程 A 使用某个对象 而此对象又需要使用某个对象 而此对象又需要 线程线程 B 修改后才能符合修改后才能符合 A 线程的需要 这时线程线程的需要 这时线程 A 就就 要等待线程要等待线程 B 完成修改工作 这种现象称为 完成修改工作 这种现象称为 1分分 A 线程的同步 线程的同步 B 线程的互斥 线程的互斥 C 线程的调度 线程的调度 43 StringBuffer 类的字符对象的长度是 类的字符对象的长度是 B A 固定长度固定长度 B 可变长度可变长度 C 长度长度 必须小于必须小于16个字符个字符 D 长度必须大于长度必须大于16个字符个字符 44 对于 对于 catch 子句的排列 下列正确的是 子句的排列 下列正确的是 A 父类在前 子类在后父类在前 子类在后 B 父类在后 父类在后 子类在前子类在前 C 有继承关系的异常类不能在同一个有继承关系的异常类不能在同一个 try 内内 D 必须有必须有 Exception 类的类的 Catch 捕捉捕捉 45 有如下程序段 有如下程序段 int total 0 for int i 0 i 4 i if i 1 continue if i 2 break total i 则执行完该程序段后则执行完该程序段后 total 的值为 的值为 A 0B 1 C 3D 6 46 有整型数组 有整型数组 int x 12 35 8 7 2 则调用则调用 方法方法 Arrays sort x 后 数组后 数组 x 中的元素值依次是 中的元素值依次是 A 2 7 8 12 35 B 12 2 35 8 7 C 35 12 8 7 2 D 8 7 12 35 2 二 阅读下列程序 写出程序运行结果 二 阅读下列程序 写出程序运行结果 1 class A int x y A int xx int yy x xx y yy interface A3202 int f3202 A a interface B3202 int g3202 public class C3202 extends A implements A3202 B3202 A a new A x y C3202 int x int y super x y this x x x this y y y public int f3202 A a return x a x x a y public int g3202 return x a x x a y public static void main String args int x 10 y 20 A a new C3202 x y C3202 c new C3202 x y System out println a x a y System out println c f3202 a System out println c g3202 2 class A B obj A obj new B obj print System out println AAA class B public void print System out println BBB public class Class3202 public static void main String arg A obj new A 考答案 程序运行结果 考答案 程序运行结果 BBB AAA 3 写出下面程序的运行结果 写出下面程序的运行结果 public class Class34ThreadTest public static void main String args Hello h new Hello Thread t new Thread h t start class Hello implements Runnable int i public void run while true System out println Hello i if i 5 break 4 publicpublic classclass AAAAaAAAAa publicpublic staticstatic voidvoid main Stringmain String arg arg StringString str con index php str con index php StringString regex regex StringString s str split regex s str split regex for intfor int i 0 i s length i i 0 i s length i System out println s i System out println s i a a和和b b是两个是两个LinkedListLinkedList对象 各对象 各addadd一些元素 一些元素 ListList a a和和 b b newnew LinkedList LinkedList a add A a add A a add A a add A a adda add A a add A a add A a add A a add A a add A A a add A b add b b add b b add b b add b b addb add b b add b b add b b add b b add b b add b b b add b ListIteratorListIterator aIteraIter a listIterator a listIterator IteratorIterator bIterbIter b iterator b iterator whilewhile bIter hasNext bIter hasNext ifif aIter hasNext aIter next aIter hasNext aIter next aIter add bIter next aIter add bIter next System out println a System out println a 6 importimport java io java io publicpublic classclass CCCCCCCCCC publicpublic staticstatic voidvoid main Stringmain String args args FileFile file newfile new File hello txt File hello txt charchar b b 北京欢迎你北京欢迎你 toCharArray toCharArray try try FileWriterFileWriter out newout new FileWriter file writingFileWriter file writing out write b out write b out write out write 你好中国你好中国 out close out close FileReaderFileReader in newin new FileReader file readingFileReader file reading intint n 0 n 0 while n in read b 0 2 1 while n in read b 0 2 1 StringString str newstr new String b 0 2 String b 0 2 System out println str System out println str in close in close catch IOExceptioncatch IOException e e System out println e System out println e System out println b newSystem out println b new String b String b 7 7 写出下面程序的运行结果写出下面程序的运行结果 staticstatic intint x x staticstatic intint Add intAdd int y y x x x x y y returnreturn x x publicpublic staticstatic voidvoid main String main String args args TODOTODO Auto generatedAuto generated methodmethod stubstub Add 1 Add 1 System out printf n d Add 20 System out printf n d Add 20 Add 3 Add 3 System out printf n d Add 40 8 classclass ancestorClassancestorClass privateprivate intint a 8 a 8 protectedprotected intint b 15 b 15 voidvoid f f System out print a b System out print a b voidvoid g g System out print ancestorClass System out print ancestorClass FunctionFunction g g hashas beenbeen called called publicpublic classclass TestTest extendsextends ancestorClassancestorClass intint c 5 c 5 publicpublic voidvoid f f System out println b c System out println b c publicpublic voidvoid testfun testfun System out println son System out println son functionfunction testfuntestfun hashas beenbeen called called publicpublic staticstatic voidvoid main Stringmain String args args ancestorClassancestorClass sc newsc new ancestorClass ancestorClass sc f sc f sc g sc g sc newsc new Test Test Test sc testfun Test sc testfun 9 class Test float F public double getF float F F return this F public static void main String args System out println new Test getF 10 10 文件读写 ByteArrayOutputStream out new ByteArrayOutputStream for int i 1 i 13 i i 5 out write i ByteArrayInputStream in new ByteArrayInputStream out toByteArray int n 1 while n in read 1 System out printf nc ch ar n 11 classclass putOutDataputOutData extendsextends ThreadThread public public voidvoid run run for intfor int i 2 i 10 i i 2 i 10 i System out printSystem out print i i classclass TestTest publicpublic staticstatic voidvoid main Stringmain String args args throwsthrows InterruptedExceptionInterruptedException Thread Thread th newth new putOutData putOutData th start th start System out print System out print 程序结束啦 程序结束啦 12 字符串创建时的区别 字符串创建时的区别 String ss I Like ahut String ssss new String ss String sss I Like ahut System out printf b ss ssss System out printf b ss equals sss System out printf b ssss equals s ss 是比较什么的 是比较什么的 Equals是比较什么的 直接是比较什么的 直接 复制和复制和new String 的区别 的区别 四 简答四 简答 1 什么是上转型对象 什么是上转型对象 2 什么叫接口回调 什么叫接口回调 3 什么是正则表达式 写出与模式 什么是正则表达式 写出与模式 A 13568 3 匹配的几匹配的几 个字符串 个字符串 4 程序 线程和进程的关系 程序 线程和进程的关系 5 线程有 线程有 4 种状态 种状态 6 FileInputStream 流的流的 read 方法和 方法和 FileReader 流的流的 read 方法有何不同 它们的文件输出流分别对应哪个类 方法有何不同 它们的文件输出流分别对应哪个类 7 java 的方法重写继承的方法的规则是什么 覆盖或重写是的方法重写继承的方法的规则是什么 覆盖或重写是 什么 什么 8 String 和和 StringBuffer 的区别 的区别 9 子类继承方法时 可以降低方法的访问权限吗 子类继承方法时 可以降低方法的访问权限吗 10 重载是什么 重载是什么 11 抽象类的特点 抽象类的特点 12 接口的特点 接口的特点 五 程序设计题五 程序设计题 1 编写一个方法 编写一个方法 string3703 要求在一个字符串数组 要求在一个字符串数组 中找出长度最长的一个元素 其中字符串数组是方法的中找出长度最长的一个元素 其中字符串数组是方法的 参数 最长的一个元素是方法的返回值 参数 最长的一个元素是方法的返回值 6分分 参考答案 方法如下 参考答案 方法如下 String string3703 String a String maxStr a 0 for int i 1 i a length i if maxStr length a i length maxStr a i return maxStr 解析 完整的程序如下 解析 完整的程序如下 public class Class3703 static String string3703 String a String maxStr a 0 for int i 1 ia i length maxStr a i return maxStr public static void main String args String b asdf saffdfd as System out println string3703 b 输出结果为 输出结果为 as 2 应用程序 求整数文件应用程序 求整数文件 intfile1 txt 中各行整数的中各行整数的 和 并把和存入到另一个文件和 并把和存入到另一个文件 intfile2 txt 中 设中 设 整数文件中全是整数 整数序列被分成行 各行整整数文件中全是整数 整数序列被分成行 各行整 数个数不等且用空格分隔 要求程序将文件中各行数个数不等且用空格分隔 要求程序将文件中各行 整数的和及乘积输出在另一个文件中 整数的和及乘积输出在另一个文件中 6分分 infile1 Txt Infile2 txt 1 2 3 4 10 24 1 2 3 6 6 5 6 11 30 参考答案 程序如下 参考答案 程序如下 import java io import java util public class Class3803 public static void main String args RandomAccessFile in out try in intfile1 txt 使用使用 Filereader BufferedReader out intfile2 txt 使用使用 FIleWriter BufferedWriter 自己补充完整自己补充完整 String s while s in readLine null StringTokenizer token new StringTokenizer s long s 1 while token hasMoreTokens s nteger parseInt token nextToken out write sum in close out close catch FileNotFoundException e System out println 文件找不到 文件找不到 e catch IOException e System out println 文件读写错 文件读写错 e 3 接口Shape中包含求面积和周长的方法 interface Shape double 求面积求面积 double 求周长求周长 要求实现设计圆类和长方形类实现该接口 实现接要求实现设计圆类和长方形类实现该接口 实现接 口的两个方法 并测试之 口的两个方法 并测试之 Class Cricle 实现接口实现接口 Class Rectangle 实现接口实现接口 4 a import java util b c public class Example d e public static void main String args f g Integer one new Integer 1 h two new Integer 2 i three new Integer 3 j four new Integer 4 k five new Integer 5 l six new Integer 6 m HashSet A new HashSet n B new HashSet o tempSet new HashSet p A add one A add two A add thr ee A add four q B add one B add two B add fiv e B add six r tempSet HashSet A c lone s t A removeAll B A B 差集差集 A u B removeAll tempSet B A 的差的差 集集 v B addAll A A B U B A B w int number B size x System out println A 和和 B 的对称的对称 差集合中有差集合中有 number 个元素个元素 y Iterator iter B i
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- GB/T 12459-2025钢制对焊管件类型与参数
- 亲子餐厅免责协议书
- 入股经营吊车协议书
- 江苏南通滨海园区控股发展限公司招考工作人员易考易错模拟试题(共500题)试卷后附参考答案
- 出租球场经营协议书
- 养老院投资合同协议
- 广州市白云区总工会2025年下半年招考工会组织员易考易错模拟试题(共500题)试卷后附参考答案
- 机械合伙购买协议书
- 医疗垃圾签署协议书
- 写二手车合同协议书
- 纺织概论全套-课件
- 农业经济管理专业毕业实习报告范文
- 公路工程风险管控措施清单
- 肺结核咯血的护理查房
- 招飞面试问题及答案
- 形容词比较级和最高级课件
- 业财融合背景下的管理会计研究
- 同首古诗涉及高考古典诗歌阅读核心考点核心题型展示课件
- 幼儿园小班数学练习题及答案
- 临床护理实践指南手术室器械传递
- 消防学员心理测试题及答案
评论
0/150
提交评论