做前声明:
此系统包括了Java中:面向对象-封装、String-StringBuilder、ArrayList集合、继承-抽象-final、static-接口-多态、四大权限符-Object类-各种代码块-各种API-System类、包装类-String的常用方法-引用类型的使用、Collection集合-Linst接口-ArrayList-LinKedList-泛型-高级反省-数据结构、异常-线程、线程安全问题-解决方案-并发包、线程池-线程池状态-Timer计时器-Lambda表达式-Stream流、File-递归-IO流-字节流、字符流-IO流异常处理-持久的属性集-缓冲流-转换流-序列化流、Junit单元测试-网络编程入门-TCP通信程序、NIO-AIO、反射概述-反射操作类的成员-注解-动态代理、正则表达式
建议:
复制到编译器中执行。
题中或多或少会出现一些字意的问题,请忽略就好,根据具体意思可以完成。
package 选择题考试系统;
import java.util.*;
/**
* @title: Examination
* @Author Чжан Синь
* @Date: 2021/4/6 17:40
* @Version 1.4
*/
public class Examination {
public static Scanner sc = new Scanner(System.in);
static int score = 0;
static long start = 0;
static long end = 0;
public static void main(String[] args) {
System.out.println("--------------------选择题测试--------------------");
HashMap<String,String> map = new HashMap<>();
map.put("关于this关键字,下面说法正确的是:()\n" +
"\n" +
"A:this关键字可以区分成员变量和局部变量;\n" +
"\n" +
"B:this关键字可以用来在构造函数中调用其它构造函数;\n" +
"\n" +
"C:this关键字可以用在函数中,表示对调用这个函数的对象的引用;\n" +
"\n" +
"D:以上说法都是正确的;","D");
map.put("关于Java的继承,下面说法正确的是:()\n" +
"\n" +
"A:子类继承父类,可以继承父类所有成员;\n" +
"\n" +
"B:子类继承父类,可以继承父类一般函数和构造函数;\n" +
"\n" +
"C:子类继承父类,可以继承父类非私有成员;\n" +
"\n" +
"D:子类继承父类,不能继承父类构造函数;","D");
map.put("关于Java的继承,下面说法正确的是:()\n" +
"\n" +
"A:一个类只能同时继承一个父类;\n" +
"\n" +
"B:一个类可以同时继承多个父类;\n" +
"\n" +
"C:一个类只能有一个子类;\n" +
"\n" +
"D:一个类可以继承任何一个其他类;","A");
map.put("下面说法正确的是:()\n" +
"\n" +
"A:方法重写就是指,在同一个类中允许存在多个名称相同,但参数列表不同的函数;\n" +
"\n" +
"B:方法重写与方法返回值类型无关\n" +
"\n" +
"C:方法重写时,子类重写的方法是否使用static关键字修饰,应该根据具体需求确定;\n" +
"\n" +
"D:方法重写时,子类重写的方法的访问权限,不能比父类被重写方法的访问权限低;","D");
map.put("下面说法正确的是:()\n" +
"\n" +
"A:一般开发中,子类应该重写父类所有方法;\n" +
"\n" +
"B:一般开发中,子类应该重写父类不满足子类需要的方法;\n" +
"\n" +
"C:一般开发中,子类很少重写父类方法;\n" +
"\n" +
"D:上面说法都不正确;","B");
map.put("下面说法正确的是:()\n" +
"\n" +
"A:子类实例化时,要先创建父类对象,然后再创建子类对象;\n" +
"\n" +
"B:子类实例化时,先创建子类对象,再创建父类对象;\n" +
"\n" +
"C:子类实例化时,先调用子类构造函数进栈,然后再子类构造函数中通过super语句调用父类构造函数,执行完父类构造函数再执行子类构造函数;\n" +
"\n" +
"D:子类实例化时,先调用父类构造函数进栈,执行完毕再执行子类构造函数;","C");
map.put("下面说法正确的是:()\n" +
"\n" +
"A:因为抽象类不能创建对象,所以抽象类没有构造函数;\n" +
"\n" +
"B:抽象类就是有抽象方法的类;\n" +
"\n" +
"C:抽象类中只能书写抽象方法;\n" +
"\n" +
"D:子类继承抽象父类,应该实现父类中所有抽象函数,否则这个子类也应该是抽象类;\n" +
"\n","D");
map.put("下面说法错误的是:()\n" +
"\n" +
"A:因为抽象类不能创建对象,所以需要由子类继承;\n" +
"\n" +
"B:子类继承抽象父类,应该重写父类中所有函数;\n" +
"\n" +
"C:如果一个类中有抽象方法,这个类一定是抽象类;\n" +
"\n" +
"D:抽象方法是用来表示描述不清的功能的;","B");
map.put("下面说法正确的是:()\n" +
"\n" +
"A:final修饰构造函数,表示子类不能重写;\n" +
"\n" +
"B:final关键字可以修饰Object类;\n" +
"\n" +
"C:final可以修饰成员变量,不能修饰局部变量;\n" +
"\n" +
"D:final不能修饰抽象方法,因为抽象方法必须被子类重写,而final修饰的方法不能被子类重写;","D");
map.put("下面说法正确的是:()\n" +
"\n" +
"A:修饰方法时,abstract关键字不能和final、static关键字一起使用,但可以和private一起使用;\n" +
"\n" +
"B:非静态成员内部类中可以书写任意成员;\n" +
"\n" +
"C:final修饰引用类型的变量,变量中保存的引用地址不能改,但是引用指向的对象中的数据可以改;\n" +
"\n" +
"D:抽象类的构造函数不能是私有的;","C");
map.put("下面代码编译运行结果是:\r\n" +
"interface A{}\n" +
" class B implements A{\n" +
" public String func()\n" +
" {\n" +
" return \"func\";\n" +
" }\n" +
" }\n" +
" class Demo {\n" +
" public static void main(String[] args) {\n" +
" A a = new B();\n" +
" System.out.println(a.func());\n" +
" }\n" +
" }\r\n" +
"A:编译出错;\r\n" +
"B:编译通过,但运行出错;\r\n" +
"C:编译运行都正常,输出”func”\r\n" +
"D:编译运行都正常,但没有任何输出结果;","A");
map.put("下面说法正确的是:()\n" +
"\n" +
"A:多态就是父类型引用操作子类对象,或者接口类型引用操作实现类对象;\n" +
"\n" +
"B:多态可以提高程序的复用性和耦合性;\n" +
"\n" +
"C:多态中父类型引用不能操作子类特有成员,因为运行时发现父类中没有子类的特有成员;\n" +
"\n" +
"D:多态的好处是不需要使用子类特有成员,降低程序的复杂度;","A");
map.put("下面代码编译运行结果是:()\r\n" +
"A:编译失败\r\n" +
"class Fu{\n" +
" int num = 4;\n" +
" void show(){\n" +
" System.out.println(\"showFu\");\n" +
" }\n" +
" }\n" +
" class Zi extends Fu{\n" +
" int num = 5;\n" +
" void show(){\n" +
" System.out.println(\"showZi\");\n" +
" }\n" +
" }\n" +
" public class Test{\n" +
" public static void main(String[] args) {\n" +
" Fu f = new Zi();\n" +
" Zi z = new Zi();\n" +
" System.out.println(f.num);\n" +
" System.out.println(z.num);\n" +
" f.show();\n" +
" z.show();\n" +
" }\n" +
" }\r\n" +
"B:编译成功,但运行出错\r\n" +
"C:编译运行都成功,输出4,5,showFu,showZi\r\n" +
"D:编译运行都成功,输出4,5,showZi,showZi","D");
map.put("下面说法正确的是:()\n" +
"\n" +
"A:Java中的接口使用interface关键字声明,在接口中只能书写抽象函数和使用public\tstatic \tfinal修饰的成员变量;\n" +
"\n" +
"B:Java中的抽象类可以继承多个接口;\n" +
"\n" +
"C:Java中的接口里面没有构造函数;\n" +
"\n" +
"D:Java中的类可以同时实现多个接口,一个接口也可以继承多个接口,没有任何限制;","C");
map.put("下面说法正确的是:()\n" +
"\n" +
"A:抽象类和接口都一定有抽象方法,不能直接创建对象,需要由子类继承或者实现;\n" +
"\n" +
"B:抽象类和接口中都没有构造方法,不能直接创建对象;\n" +
"\n" +
"C:抽象类是用来描述一个继承体系中所有子类的共有属性和行为的;接口更多的用来描述功能的集合,用来定义规则的;\n" +
"\n" +
"D:接口和抽象类都只能是单一继承;","C");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:Java中,一般使用static和final关键字共同修饰的成员变量表示常量;\n" +
"\n" +
"B:Java中,使用private关键字修饰的成员,只能在本类中使用,不能在其他类中使用;\n" +
"C:Java中,要想避免一个方法被子类重写,应该使用final关键字修饰;\n" +
"\n" +
"D:Java中,protected修饰符修饰的成员,可以被不同包中的子类继承;","B");
map.put("下面说法正确的是:()\n" +
"\n" +
"A:static关键字可以修饰类中所有成员;\n" +
"\n" +
"B:static关键字不能用来修饰构造方法;\n" +
"\n" +
"C:static关键字不能修饰类;\n" +
"\n" +
"D:static关键字修饰的方法中可以使用this关键字;","B");
//该第三章了
map.put("以下关于Object类,说法错误的是? ()\n" +
"\n" +
"A: 任何类都间接或者直接继承Object类\n" +
"\n" +
"B: Object是所有类的根类(父类)\n" +
"\n" +
"C: 任何一个类都可以使用Object类中的方法\n" +
"\n" +
"D: Object类中的方法不能被重写","D");
map.put(" 下面说法错误的是:\n" +
"\n" +
"A:Object类是Java中最高父类,其它所有类都直接或者间接的继承Object类;\n" +
"\n" +
"B:Java中,如果一个类没有明确书写继承的类,则默认都继承Object类;\n" +
"\n" +
"C:Object类型的变量,可以指向Java中任意一个对象;\n" +
"\n" +
"D:Object类是一个抽象类,所有Java类都具有Object类中定义的方法;","D");
map.put("下面对于toString()方法和equals()方法描述正确的是? \n" +
"\n" +
"A: 类重写toString()方法是为了打印对象的地址\n" +
"\n" +
"B: 类重写equals()方法是为了比较对象的地址\n" +
"\n" +
"C: 类重写toString()方法是打印对象中的属性,重写equals()是比较对象中的属性\n" +
"\n" +
"D: 类只能重写Object中的toString()方法和equals()方法","C");
map.put("下面说法错误的是:()\n" +
"\n" +
"A:toString方法会返回一个字符串,在使用System.out.println()语句输出对象时就是输出的这个方法返回的数据;\n" +
"\n" +
"B:String类已经重写了toString和equals方法;\n" +
"\n" +
"C:一般开发中都需要重写toString方法和equals方法\n" +
"\n" +
"D:equals方法底层使用的是 == 比较的,所以是用来比较两个对象是否是同一个对象的;","D");
map.put("观察下列代码.日期格式化为字符串是(时间忽略)? ()\n" +
"public class SimpleDateFormatDemo {\n" +
"\n" +
" public static void main(String[] args) throws ParseException {\n" +
" SimpleDateFormat sdf = new SimpleDateFormat(\"yyyy年MM月dd日 HH:mm:ss\");\n" +
" Date date = new Date();\n" +
" String s = sdf.format(date);\n" +
" System.out.println(s);\n" +
" }\n" +
"}\n" +
"A: 2018/04/11 22:01:30\n" +
"\n" +
"B: 2018年04月11日 22:01:30\n" +
"\n" +
"C: 2018.04.11 22:01:30\n" +
"\n" +
"D: 2018-04-11 22时01分30秒","B");
map.put(" 想得到\"2018-04-11 22时12分10秒\"(时间忽略),模式正确的是?:\n" +
"public class SimpleDateFormatDemo {\n" +
"\n" +
" public static void main(String[] args) throws ParseException {\n" +
" //此处代码应填写\n" +
" Date date = new Date();\n" +
" String s = sdf.format(date);\n" +
" System.out.println(s);\n" +
" }\n" +
"}\n" +
"A: SimpleDateFormat sdf = new SimpleDateFormat(\"yyyy年MM月dd日 HH:mm:ss\");\n" +
"\n" +
"B: SimpleDateFormat sdf = new SimpleDateFormat(\"yyyy-MM-dd HH时mm分ss秒\");\n" +
"\n" +
"C: SimpleDateFormat sdf = new SimpleDateFormat(\"yyyy/MM/dd HH时mm分ss秒\");\n" +
"\n" +
"D: SimpleDateFormat sdf = new SimpleDateFormat(\"yyyy.MM.dd HH:mm:ss\");","B");
map.put(" 阅读代码,横线位置应填写的内容是? ()\n" +
"public class SimpleDateFormatTest {\n" +
"\n" +
" public static void main(String[] args) throws ParseException {\n" +
" String str = \"1998-01-01\";\n" +
" SimpleDateFormat sdf = new SimpleDateFormat(_____);\n" +
" Date date = sdf.parse(str);\n" +
" System.out.println(date);\n" +
" }\n" +
"}\n" +
"A: \"yyyy-MM-dd\"\n" +
"\n" +
"B: \"yyyy年MM月dd\"\n" +
"\n" +
"C: \"yyyy/MM/dd\"\n" +
"\n" +
"D: \"yyyy.MM.dd\"\n" +
"\n","A");
map.put("下面说法错误的是:()\n" +
"\n" +
"A:Java中表示时间的类是util包中的Date类;\n" +
"\n" +
"B:Date类的对象表示一个时间段;\n" +
"\n" +
"C:Date类中从时间中获取年月日的方法过时了,开发中应该使用Calendar类的方法实现;\n" +
"\n" +
"D:Date类中将时间格式化为字符串的方法过时了,开发中应该使用DateFormat或者SimpleDateFormat类;","B");
map.put("下面说法错误的是:()\n" +
"\n" +
"A:Java中表示时间的类是util包中的Date类;\n" +
"\n" +
"B:Date类的对象表示一个时间段;\n" +
"\n" +
"C:Date类中从时间中获取年月日的方法过时了,开发中应该使用Calendar类的方法实现;\n" +
"\n" +
"D:Date类中将时间格式化为字符串的方法过时了,开发中应该使用DateFormat或者SimpleDateFormat类;","D");
map.put("读代码,控制台输出的结果为? ()\n" +
"public class IntegerDemo {\n" +
" public static void main(String[] args) {\n" +
" String str = \"123\";\n" +
" System.out.println(str + 10);\n" +
" int i = Integer.parseInt(str);\n" +
" System.out.println(i + 10);\n" +
" }\n" +
"}\n" +
"A: 12310,133\n" +
"\n" +
"B: 133,13310\n" +
"\n" +
"C: 12310,13310\n" +
"\n" +
"D: 133,133","A");
map.put("阅读代码,控制台输出的结果为? ()\n" +
"public class IntegerDemo {\n" +
" public static void main(String[] args) {\n" +
" String str = \"1a3\";\n" +
" Integer it = new Integer(str);\n" +
" int i = it.intValue();\n" +
" System.out.println(i);\n" +
" }\n" +
"}\n" +
"A: 1a3\n" +
"\n" +
"B: 13\n" +
"\n" +
"C: 运行报错,字符串内容必须是数字字符\n" +
"\n" +
"D: 1","C");
map.put("阅读代码,控制台要打印110横线需要填写什么? ()\n" +
"public class IntegerDemo {\n" +
" public static void main(String[] args) {\n" +
" int i = 1;\n" +
" Integer it = new Integer(i);\n" +
" String s = ___;\n" +
" System.out.println(s + 10);\n" +
" }\n" +
"}\n" +
"A: it\n" +
"\n" +
"B: it.toString();\n" +
"\n" +
"C: i\n" +
"\n" +
"D: 110","B");
map.put("阅读代码,控制台打印的结果为? ()\n" +
"public class IntegerDemo {\n" +
" public static void main(String[] args) {\n" +
" int i = 10;\n" +
" String str = i + \"\";\n" +
" System.out.println(str.equals(\"10\"));\n" +
" }\n" +
"}\n" +
"A: false\n" +
"\n" +
"B: true\n" +
"\n" +
"C: 运行报错\n" +
"\n" +
"D: 0","B");
map.put("下面说法错误的是:()\n" +
"\n" +
"A:System类提供了数组复制的方法;开发中如果遇到数组复制的需求,使用它更高效;\n" +
"\n" +
"B:Math类主要提供各种常见的数学运算的方法,而且全部都是静态的方法;\n" +
"\n" +
"C:自动装箱和自动拆箱是JDK5出现的新技术,主要用来简化包装类对象和基本类型数据之间的转换的;\n" +
"\n" +
"D:正则表达式是Java中独有的用来匹配字符串的技术;\n" +
"\n","D");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:数组可以保存基本类型和引用类型数据,而且一个数组只能保存一种类型的数据;\n" +
"\n" +
"B:一般开发中,会使用一个集合容器保存不同类型的数据\t\n" +
"C:字符串缓冲区的容量可以自动增长,而且能够把添加的数据都转换为字符类型的数据;\n" +
"\n" +
"D:集合中只能保存引用类型数据,不能保存基本类型数据;","B");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:Java中的数据可以保存在变量或者容器中;\n" +
"\n" +
"B:Java中的容器包括数组、字符串缓冲区和集合;\n" +
"\n" +
"C:Java中的数组一旦创建,容量不能更改;\n" +
"\n" +
"D:Java中数组只能保存引用类型数据;","D");
map.put("下列属于List集合的特点是?()\n" +
"\n" +
"A: 它是一个元素存取无序的集合\n" +
"\n" +
"B: 它是一个不带有索引的集合\n" +
"\n" +
"C: 能通过索引操作集合中的元素\n" +
"\n" +
"D: 集合中不能有重复的元素","C");
map.put("下面代码运行结果是? ()\n" +
"List arr=new ArrayList();\n" +
"arr.add(\"java\");\n" +
"arr.add(\"world\");\n" +
"arr.add(\"hello\");\n" +
"arr.add(\"java\");\n" +
"arr.remove(\"java\");\n" +
"System.out.println(arr.contains(\"java\"));\n" +
"A: false\n" +
"\n" +
"B: true\n" +
"\n" +
"C: null\n" +
"\n" +
"D: 运行出错","B");
map.put("下列说法错误的是:\n" +
"\n" +
"A:增强for循环可以用来遍历数组和集合;\n" +
"\n" +
"B:增强for循环遍历集合时,不能修改集合,因为底层还是使用迭代器迭代集合;\n" +
"\n" +
"C:使用增强for循环遍历数组,冒号左边写的是数组下标;\n" +
"\n" +
"D:增强for循环书写更简单,所以迭代集合时一般都有增强for循环;\n" +
"\n","C");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:迭代器是用来迭代集合容器的;\n" +
"\n" +
"B:一个迭代器可以对一个集合迭代多次;\n" +
"\n" +
"C:迭代器只能从头到尾迭代,不能倒着迭代;\n" +
"\n" +
"D:迭代器迭代集合时,不能使用迭代器之外的方法更改集合容器中数据;","B");
map.put("下面说法错误的是:()\n" +
"\n" +
"A:泛型是用来在编译期对数据类型进行强制检查的;\n" +
"\n" +
"B:泛型是Java中集合的特有技术;\n" +
"\n" +
"C:泛型在程序编译后就消失了,运行期没有泛型存在,这叫做泛型的擦除;\n" +
"\n" +
"D:泛型就是类型的变量;定义在类上的泛型,在创建对象时就要赋值,而且类中的静态成员不能使用类上的泛型;","B");
map.put("下列有关栈结构的特点说法正确的是? ()\n" +
"\n" +
"A: 查找元素快\n" +
"\n" +
"B: 先进后出\n" +
"\n" +
"C: 先进先出\n" +
"\n" +
"D: 增删元素慢","B");
map.put("下面关于队列结构描述正确的是? ( )\n" +
"\n" +
"A: 允许在表的任意一端插入和删除\n" +
"\n" +
"B: 先进后出\n" +
"\n" +
"C: 队列的入口、出口各占一侧\n" +
"\n" +
"D: 增删元素慢","C");
map.put("下列不属于数组结构的特点是? ()\n" +
"\n" +
"A: 是有序的元素序列\n" +
"\n" +
"B: 查找元素快\n" +
"\n" +
"C: 增删元素慢\n" +
"\n" +
"D: 先进后出","D");
map.put("下列属于数组结构在内存中的特点是? ()\n" +
"\n" +
"A: 相邻的两个元素使用地址值进行连接\n" +
"\n" +
"B: 是连续的内存空间\n" +
"\n" +
"C: 先进后出\n" +
"\n" +
"D: 先进先出","B");
map.put("下列有关单向链表说法不正确的是? ()\n" +
"\n" +
"A: 增删元素快\n" +
"\n" +
"B: 查找元素快\n" +
"\n" +
"C: 查找元素慢\n" +
"\n" +
"D: 多个结点之间,通过地址进行连接","B");
map.put("关于单向链表描述正确的是?()\n" +
"\n" +
"A: 每个结点包括两个部分:一个是存储数据元素的数据域,另一个是存储下一个结点地址的指针域\n" +
"\n" +
"B: 每个结点包括三个部分:一个是存储上一个结点地址的指针域,一个是存储数据元素的数据域,另一个是存储下一个结点地址的指针域\n" +
"\n" +
"C: 最后一个节点的指针域一定指向首节点的地址\n" +
"\n" +
"D: 想要获取这个节点的数据,不必先获得上一个节点","A");
map.put("下面说法错误的是:()\n" +
"\n" +
"A:栈就有先进后出的特点;\n" +
"\n" +
"B:队列具有先进先出的特点;\n" +
"\n" +
"C:链表容量可以自动增长,具有增删快查询慢的特点;\n" +
"\n" +
"D:可变数组容量不能自动增长,具有增删慢查询快的特点;\n" +
"\n","D");
map.put("观察下列代码\n" +
"\n" +
"```java \n" +
"HashMap map = new HashMap<>();\n" +
"map.put(new Phone(\"锤子\",1799),\"top1\" );\n" +
"map.put(new Phone(\"小米\",1999),\"top2\");\n" +
"map.put(new Phone(\"小米\",1999),\"top3\");\n" +
"```\n" +
"\n" +
"下面描述错误的是? ( )\n" +
"\n" +
"A: 如果Phone类正确重写hashCode和equals方法,会存进去三条数据.\n" +
"\n" +
"B: 如果Phone类正确重写了hashCode和equals方法,会存进去两条数据.\n" +
"\n" +
"C: 如果Phone类正确重写了hashCode和equals方法,小米手机的热度值会变成top3.\n" +
"\n" +
"D: Phone类如果放在值的位置上则不需要重写hashCode和equals方法.\n" +
"\n","A");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:Collection集合是单列集合,因为保存的数据都是一个一个的;\n" +
"\n" +
"B:Map集合是双列集合,因为保存的数据都是一对一对的;\n" +
"\n" +
"C:Map集合也是Collection集合框架的一部分,用来保存有对应关系的一对对的数据;\n" +
"\n" +
"D:Map集合不属于Collection集合;","C");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:Map集合中键都是唯一的;\n" +
"\n" +
"B:Map集合中一个键只能对应一个值;\n" +
"\n" +
"C:Map集合中值不是唯一的,多个键可以对应到一个值;\n" +
"\n" +
"D:Map集合不允许使用null作为键和值;\n" +
"\n","D");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:一个Map集合可以返回三个集合,分别是键集、值集和键值对集;\n" +
"\n" +
"B:因为Map集合中键是唯一的,所以键集和键值对集都是不重复的Set集合;\n" +
"\n" +
"C:因为Map集合中值不是唯一的,所以值集是可以重复的List集合;\n" +
"\n" +
"D:Map中的键值对也是一类事物,使用接口Map.Entry描述;","C");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:要遍历Map集合,需要先获取集合的迭代器,然后进行得带,不能直接使用for循环迭代;\n" +
"\n" +
"B:遍历Map集合可以按照值集、键集和键值对集遍历;\n" +
"\n" +
"C:按照值集遍历Map集合,因为不能根据值获取键,所以只能遍历获取所有值;按照键集遍历则可以先获取键,再根据键得到对应的值;\n" +
"\n" +
"D:按照键值对集遍历Map集合,首先得到的是一个个键值对对象;然后需要根据键值对对象获取里面的键和值;","A");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:HashMap中的键使用哈希表保存,所以键的唯一性依赖于键对象的hashCode和equals方法;\n" +
"\n" +
"B:LinkedHashMap中的键使用哈希表保存,并且使用链表记录添加数据的顺序,所以LinkedHashMap的键能够唯一并且有序;\n" +
"\n" +
"C:可变参数本质上就是一个数组;一个函数中可变参数最多只能有一个;\n" +
"\n" +
"D:Hashtable使用哈希表保存键,所以和HashSet一样,键对象一般要重写equals和hashCode方法;如果为null,就默认放在哈希表的0下标位置;","D");
map.put("下面关于Map集合说法错误的是? ()\n" +
"\n" +
"A: Map集合存储的是一些键值对数据;\n" +
"\n" +
"B: Map集合也称为双列集合;\n" +
"\n" +
"C: Map集合的key只能存放引用数据类型的数据;\n" +
"\n" +
"D: Map集合的value能存放基本数据类型的数据也能存放引用数据类型的数据;","D");
map.put("下面关于Map集合说法正确的是? ()\n" +
"\n" +
"A: Map集合包含Collection集合;\n" +
"\n" +
"B: Map集合的常用子类有HashMap和LinkedHashMap;\n" +
"\n" +
"C: Map集合的key存放的数据是可以重复的;\n" +
"\n" +
"D: Map集合的value存放的数据要求不能重复;","B");
map.put("观察下列代码\n" +
"\n" +
"```java\n" +
"HashMap map = new HashMap<>();\n" +
"map.put(\"小米\", \"红色\");\n" +
"map.put(\"小米\", \"蓝色\");\n" +
"System.out.println(map);\n" +
"```\n" +
"\n" +
"请问,输出的结果是? ()\n" +
"\n" +
"A: 对象的地址值\n" +
"\n" +
"B: {小米:红色,小米:蓝色}\n" +
"\n" +
"C: {小米=红色,小米=蓝色}\n" +
"\n" +
"D: {小米=蓝色}","D");
map.put("观察下列代码\n" +
"\n" +
"```java\n" +
"HashMap map = new HashMap<>();\n" +
"map.put(\"张三\", 18);\n" +
"map.put(\"李四\", 20);\n" +
"map.put(\"张三\", 20);\n" +
"System.out.println(map.get(\"张三\"));\n" +
"```\n" +
"\n" +
"请问,输出的结果是? ()\n" +
"\n" +
"A: 张三:18\n" +
"\n" +
"B: 20\n" +
"\n" +
"C: 18\n" +
"\n" +
"D: 张三:20 李四:20","B");
map.put("对Map集合遍历可以根据键找值的方法说法正确的是?()\n" +
"\n" +
"A: 键找值的方法遍历map是唯一的Map遍历方法.\n" +
"\n" +
"B: 键找值的方法遍历map,必须用上keySet()方法\n" +
"\n" +
"C: 键找值的方法遍历map,可以不用get()方法.\n" +
"\n" +
"D: 键找值的方法遍历map是更为面向对象的方式.\n" +
"\n","B");
map.put("**观察下列代码**\n" +
"\n" +
"```java\n" +
"HashMap map = new HashMap<>();\n" +
"map.put(null, 0);\n" +
"Set keySet = map.keySet();\n" +
"\n" +
"for (String key : keySet) {\n" +
" System.out.println(key+\":\"+map.get(key));\n" +
"}\n" +
"```\n" +
"\n" +
"请问,输出的结果是? ()\n" +
"\n" +
"A: null:0\n" +
"\n" +
"B: 编译报错\n" +
"\n" +
"C: 运行报错\n" +
"\n" +
"D: 不报错,也没输出\n" +
"\n","A");
map.put("关于使用根据键值对找键和值对Map集合遍历的方式说法错误的是? ()\n" +
"\n" +
"A: Map集合不能直接使用迭代器或增强for遍历.获取所有的键值对对象以后就可以使用了.\n" +
"\n" +
"B: Map集合是通过keySet()方法获取所有的键值对对象的.\n" +
"\n" +
"C: Map集合通过entrySet()方法获取所有的键值对对象.返回值是Set集合.\n" +
"\n" +
"D: 根据键值对找键和值遍历方式遍历Map集合,相对根据键找值的方式更为面向对象","B");
map.put("下列关于HashMap存储自定义类型键值对数据说法错误的是? ( )\n" +
"\n" +
"A: Map集合可以存储自定义类型的数据.\n" +
"\n" +
"B: Map集合存储自定义类型数据时.自定义类型数据可以放在键或者值的位置.\n" +
"\n" +
"C: 自定义类型数据放在键上就必须重写该类的hashCode和equals方法.才能保证元素唯一性.\n" +
"\n" +
"D: 自定义类型数据放在值上就必须重写该类的hashCode和equals方法.才能保证元素唯一性.\n" +
"\n","D");
map.put("下面说法错误的是:()\n" +
"\n" +
"A:List集合都具有索引,可以根据下标精确的操作某个元素;\n" +
"\n" +
"B:Set集合没有下标,所以不能根据索引操作具体某个元素;\n" +
"\n" +
"C:List集合都是有序的,Set集合都是无序的;\n" +
"\n" +
"D:List集合可以保存重复元素,Set集合不能保存重复元素;","C");
map.put("下面说法错误的是:()\n" +
"\n" +
"A:ArrayList集合判断容器中是否包含指定元素,需要遍历集合,使用equals方法判断是否相等;\n" +
"\n" +
"B:HashSet底层使用哈希表保存数据,通过对象的hashCode方法和equals方法保证对象的唯一性;\n" +
"\n" +
"C:LinkedHashSet底层使用哈希表保存数据,保证数据的唯一性;使用链表结构保证数据的有序性;\n" +
"\n" +
"D:哈希表只能保存非null数据;","D");
map.put("下面代码运行结果是?()\n" +
"\n" +
"```java\n" +
"HashSet set = new HashSet();\n" +
"set.add(\"cba\");\n" +
"set.add(\"abc\");\n" +
"set.add(\"bac\"); \n" +
"set.add(\"cba\"); \n" +
"\n" +
"for (int i = 0; i < set.size(); i++) {\n" +
" System.out.println(set.get(i));\n" +
" }\n" +
"}\n" +
"```\n" +
"\n" +
"A: abc--abc--bac--cba\n" +
"\n" +
"B: abc--bac--cba\n" +
"\n" +
"C: 编译出错\n" +
"\n" +
"D: abc","C");
map.put("下列有关哈希表说法正确的是? ()\n" +
"\n" +
"A: jdk8后哈希表存储采用数组+链表+红黑树实现\n" +
"\n" +
"B: 哈希表存储采用链表+红黑树实现\n" +
"\n" +
"C: 哈希表存储采用栈+红黑树实现\n" +
"\n" +
"D: 哈希表存储采用队列+红黑树实现\n" +
"\n","A");
map.put("下面关于哈希表特点描述错误的是?()\n" +
"\n" +
"A: 在jdk8之后,当链表长度超过阈值(8)时,将链表转换为红黑树\n" +
"\n" +
"B: 同一hash值的元素都存储在一个链表里\n" +
"\n" +
"C: jdk8后哈希表存储采用数组+链表+红黑树实现\n" +
"\n" +
"D: 哈希表查询数据的效率较慢","D");
map.put("观察下列代码\n" +
"\n" +
"```java\n" +
"HashSet hs = new HashSet();\n" +
"\n" +
"Student s1 = new Student(\"张三\", 18);\n" +
"Student s2 = new Student(\"李四\", 18);\n" +
"Student s3 = new Student(\"张三\", 20);\n" +
"Student s4 = new Student(\"李四\", 18);\n" +
"\n" +
"hs.add(s1);\n" +
"hs.add(s2);\n" +
"hs.add(s3);\n" +
"hs.add(s4);\n" +
"\n" +
"for (Student s : hs) {\n" +
" System.out.println(s.getName() + \"---\" + s.getAge());\n" +
"}\n" +
"```\n" +
"\n" +
"Student类中自动生成了hashCode()和equals()方法,输出结果是? ()\n" +
"\n" +
"A: 李四---18,张三---20\n" +
"\n" +
"B: 李四---18,张三---20,张三---18\n" +
"\n" +
"C: 李四---18,张三---18,李四---18,张三---20\n" +
"\n" +
"D: 李四---18,张三---18","B");
map.put("### \n" +
"\n" +
"```java\n" +
"HashSet set = new HashSet();\n" +
"set.add(new User(\"杰克\", 18));\n" +
"set.add(new User(\"肉丝\", 17));\n" +
"set.add(new User(\"杰克\", 19));\n" +
"set.add(new User(\"肉丝\", 16));\n" +
"\n" +
"int sum=0;\n" +
"for (User u : set) {\n" +
" sum+=u.getAge();\n" +
"}\n" +
"System.out.println(sum/set.size());\n" +
"……\n" +
"```\n" +
"\n" +
"User类中自动生成了hashCode()和equals()方法,输出结果是?()\n" +
"\n" +
"A: 16\n" +
"\n" +
"B: 17\n" +
"\n" +
"C: 18\n" +
"\n" +
"D: 19","B");
map.put("观察下列代码\n" +
"\n" +
"```java\n" +
"ArrayList arr = new ArrayList();\n" +
"Student s1 = new Student(\"张三\", 16);\n" +
"Student s2 = new Student(\"李四\", 13);\n" +
"Student s3 = new Student(\"王五\", 29);\n" +
"arr.add(s1);\n" +
"arr.add(s2);\n" +
"arr.add(s3);\n" +
"\n" +
"MyComparator my = new MyComparator();\n" +
"Collections.sort(arr, my);\n" +
"\n" +
"for (Student s : arr) {\n" +
" System.out.println(s.getName());\n" +
"}\n" +
"```\n" +
"\n" +
"和\n" +
"\n" +
"```java\n" +
"public class MyComparator implements Comparator {\n" +
"\n" +
" @Override\n" +
" public int compare(Student s1, Student s2) {\n" +
" return s2.getAge() - s1.getAge();\n" +
" }\n" +
"}\n" +
"```\n" +
"\n" +
"标准Student类也给出,请问第一个代码的输出结果是? ()\n" +
"\n" +
"A: 张三,李四,王五\n" +
"\n" +
"B: 王五,李四,张三\n" +
"\n" +
"C: 王五,张三,李四\n" +
"\n" +
"D: 李四,王五,张三","C");
map.put("观察以下代码\n" +
"\n" +
"```java\n" +
"try{\n" +
" String s = \"hello\";\n" +
" String sub = s.substring(0);\n" +
" System.out.println(sub);\n" +
" s = null;\n" +
"}catch(NullPointerException e){\n" +
" System.out.println(\"空指针异常\");\n" +
"}\n" +
"```\n" +
"\n" +
"以上程序的运行结果是: ( )\n" +
"\n" +
"A: 编译会出现错误.\n" +
"\n" +
"B: 运行结果是控制台输出 \"hello\".\n" +
"\n" +
"C: 运行结果是控制台输出 \"空指针异常\".\n" +
"\n" +
"D: 运行结果是控制台输出然后输出空指针异常","B");
map.put("观察以下代码\n" +
"\n" +
"```java\n" +
"try{\n" +
" int[] arr = new int[10];\n" +
" System.out.println(arr[10]);\n" +
" arr = null;\n" +
" System.out.println(arr[0]);\n" +
"}catch(ArrayIndexOutOfBoundsException e2){\n" +
" System.out.println(\"数组角标越界\");\n" +
"}catch(NullPointerException e){\n" +
" System.out.println(\"空指针异常\");\n" +
"}\n" +
"```\n" +
"\n" +
"以上代码运行,控制台会输出什么? ( )\n" +
"\n" +
"A: 输出 \"数组角标越界\".\n" +
"\n" +
"B: 输出 \"空指针异常\".\n" +
"\n" +
"C: 输出 \"数组角标越界\" 和 \"空指针异常\".\n" +
"\n" +
"D: 代码编译报错","A");
map.put("观察以下代码\n" +
"\n" +
"```java\n" +
"public static void main(String[] args){\n" +
" int[] arr = null;\n" +
" printArr(arr);\n" +
"}\n" +
"\n" +
"public static void printArr(int[] arr) throws NullPointerException{\n" +
" for (int i = 0; i < arr.length; i++) {\n" +
" System.out.println(arr[i]);\n" +
" }\n" +
"}\n" +
"```\n" +
"\n" +
"运行以上程序,结果是:( )\n" +
"\n" +
"A: 编译报错,因为printArr方法声明了异常,在方法调用时必须做异常处理。\n" +
"\n" +
"B: 编译报错,因为不能将空值null作为参数传递给printArr方法。\n" +
"\n" +
"C: 运行报错,调用printArr方法时没有异常处理,虚拟机捕获空指针异常后,会报出异常信息并结束运行。\n" +
"\n" +
"D: 代码正常执行,没有错误,也没有输出数据,因为数组中没有元素。\n" +
"\n","C");
map.put("对于以下代码,说法正确的是: ( )\n" +
"\n" +
"```java\n" +
"public static void main(String[] args) throw ParseException {\n" +
" SimpleDateFormat format = new SimpleDateFormat(\"yyyy-MM-dd\");\n" +
" String s1 = \"1989-12-11\";\n" +
" Date date = format.parse(s1);\n" +
"}\n" +
"```\n" +
"\n" +
"A: 编译错误,第1行,throw 不能用到方法声明上,应该改成throws\n" +
"\n" +
"B: 运行错误,因为格式化的格式与字符串的格式不匹配\n" +
"\n" +
"C: 运行没有问题\n" +
"\n" +
"D: 编译错误第行应该去掉","A");
map.put("以下关于自定义异常类错误的是: ( )\n" +
"\n" +
"A: 开发中我们可以根据自己的业务逻辑需要,自定义不同的异常类\n" +
"\n" +
"B: java提供的异常类不能完全满足开发的需求,所以要自定义异常类\n" +
"\n" +
"C: 自定义异常类,通常要调用父类有一个参数的构造函数,因为是为了初始化异常信息\n" +
"\n" +
"D: 自定义异常类跟提供的异常类没有任何关系\n" +
"\n","D");
map.put("观察以下代码\n" +
"\n" +
"```\n" +
"public class MyException extends Exception{\n" +
" public MyException(){\n" +
" }\n" +
"\n" +
" public MyException(String message){\n" +
" super(message); \n" +
" }\n" +
"}\n" +
"```\n" +
"\n" +
"以下描述正确的是:( )\n" +
"\n" +
"A: 如果某个方法抛出了这个异常,那么在使用这个方法的时候必须try-catch处理\n" +
"\n" +
"B: 如果某个方法抛出了这个异常,那么在使用这个方法的时候必须throws处理\n" +
"\n" +
"C: 如果某个方法抛出了这个异常,那么在使用这个方法的时候可以不用处理\n" +
"\n" +
"D: 如果某个方法抛出了这个异常我们可以用方式或者方式处理\n" +
"\n","D");
map.put("观察以下代码\n" +
"\n" +
"```\n" +
"public class WeightOutOfBoundsException extends Exception{\n" +
" public WeightOutOfBoundsException(){\n" +
" }\n" +
" public WeightOutOfBoundsException(String message){\n" +
" super(message); \n" +
"\n" +
" }\n" +
"}\n" +
"```\n" +
"\n" +
"```\n" +
"public class Person{\n" +
"\n" +
" private int weight;\n" +
" public Person(int weight)throws WeightOutOfBoundsException{\n" +
" if(weight < 0 || weight > 300){\n" +
" throw new WeightOutOfBoundsException(\"体重不符合要求\");\n" +
" }\n" +
" this.weight = weight;\n" +
" }\n" +
"}\n" +
"```\n" +
"\n" +
"观察以上代码,如果创建Person对象,下列哪种处理是正确的:( )\n" +
"\n" +
"A: 直接 Person person = new Person();\n" +
"\n" +
"B: 直接 Person person = new Person(70);\n" +
"\n" +
"C: 只能将 Person person = new Person(70); 只能用 try-catch语句处理一下才可以\n" +
"\n" +
"D: 可以在创建对象的方法上用关键字将这个异常声明出来\n" +
"\n","D");
map.put("以下关于并行和并发说法错误的是:( )\n" +
"\n" +
"A: 并行表示同时在运行\n" +
"\n" +
"B: 并发表示交替在运行\n" +
"\n" +
"C: java程序是基于并发的\n" +
"\n" +
"D: java程序是基于并行的","D");
map.put("以下哪种现象是在描述并发的: ( )\n" +
"\n" +
"A: 火车上大家排队使用一个卫生间\n" +
"\n" +
"B: 电影院里所有人同时看一个电影\n" +
"\n" +
"C: 课堂上老师同时给每个学生讲课\n" +
"\n" +
"D: 以上说法都正确","A");
map.put("观察以下代码\n" +
"\n" +
"```\n" +
" public static void main(String[] args){\n" +
" Thread t = new Thread(){\n" +
" public void run(){\n" +
" System.out.println(\"我爱java\");\n" +
" }\n" +
" };\n" +
" ___________________________;\n" +
" }\n" +
"```\n" +
"\n" +
"请在横线处填入适当代码,使线程开启并运行:( )\n" +
"\n" +
"A: t.run()\n" +
"\n" +
"B: t.start()\n" +
"\n" +
"C: t.run() 或者 t.start()都行\n" +
"\n" +
"D: 以上说法都不正确","B");
map.put("下面关于如何开启线程说法错误的是: ( )\n" +
"\n" +
"A: 可以使用线程对象调用run()方法开启线程;\n" +
"\n" +
"B: 只能通过线程对象或者其子类对象,调用start()方法才能开启线程\n" +
"\n" +
"C: 线程对象调用start()方法,jvm会帮我们开启一条线程,并且帮我们调用线程的run()方法;\n" +
"\n" +
"D: 创建了线程对象并不代表该线程就开始运行了","A");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:Java程序,至少有两个线程;一个是垃圾回收线程,一个是执行main函数的线程;\n" +
"\n" +
"B:所有程序中,都至少存在一个主线程;\n" +
"\n" +
"C:多线程可以让程序同时执行多个任务,所以一个程序中线程越多越好;\n" +
"\n" +
"D:多线程只是因为CPU执行速度非常快,可以再不同的任务之间迅速切换;并非同一时间点上执行多个任务;","C");
map.put("下列说法错误的是:\n" +
"\n" +
"A:Java中创建一个线程可以通过继承Runnable接口的方式;\n" +
"\n" +
"B:Java中创建一个线程可以通过继承Thread类的方式;\n" +
"\n" +
"C:Java中启动一个线程是调用start方法;\n" +
"\n" +
"D:Java中线程任务应该放在run方法中;\n" +
"\n","A");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:一个Thread类的子类的对象创建后,就启动了一个新的线程;\n" +
"\n" +
"B:当一个线程对象调用start函数时,才启动一个新的线程;\n" +
"\n" +
"C:线程启动后,不会立即执行,而是进入等待状态,等待获取CPU的执行权;\n" +
"\n" +
"D:线程运行时,如果的执行权被其他线程抢走,这个线程就会进入等待状态,和其他线程一起抢的执行权;\n" +
"\n","A");
map.put("关于同步代码块说法错误的是:()\n" +
"\n" +
"A: 同步锁对象必须唯一\n" +
"\n" +
"B: 将要一起同步执行的代码放置到同步锁的代码块中\n" +
"\n" +
"C: 添加同步代码块增加了程序的效率\n" +
"\n" +
"D: 添加同步代码块增加程序的安全性","C");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:多个线程修改同一个数据时,有可能出现错误的操作结果,叫做线程安全问题;\n" +
"B:线程安全问题发生的需要有多个线程修改同一个数据;\n" +
"C:要发生线程安全问题,需要多个线程对同一个数据进行修改操作时,CPU可以在不同的线程间来回切换;\n" +
"D:多个线程操作同一个数据,一定会出现线程安全问题;","D");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:要避免线程安全问题,应该避免使用多线程;\n" +
"B:要解决线程安全问题,可以使用同步代码块;\n" +
"C:使用同步代码块时,必须提供一个锁对象,而且这个锁对象对不同的线程来说,是同一个对象;\n" +
"D:synchronized修饰非静态方法时,锁对象是调用这个方法的对象;synchronized修饰静态方法时,锁对象是这个方法所在的类;","A");
map.put("以下有关Lambda表达式说法错误的是? ()\n" +
"\n" +
"A: Lambda表达式的可以简化代码书写\n" +
"\n" +
"B: Lambda表达式免去了使用匿名内部类的麻烦\n" +
"\n" +
"C: Lambda表达式要求接口只能有一个抽象方法\n" +
"\n" +
"D: Lambda表达式适用于任何接口\n" +
"\n","D");
map.put("有一个Student类,代码如下\n" +
"\n" +
"```java\n" +
"public class Student{\n" +
"\n" +
" private int age;\n" +
" public void setAge(int age){\n" +
" this.age=age;\n" +
" }\n" +
" public int getAge(){\n" +
" return age;\n" +
" }\n" +
"}\n" +
"```\n" +
"\n" +
"有一个测试类,代码如下:\n" +
"\n" +
"```java\n" +
"public class Test{\n" +
"\n" +
" public static void main(String[] args) {\n" +
" ArrayList list = new ArrayList();\n" +
" list.add(new Student(22));\n" +
" list.add(new Student(32));\n" +
" list.add(new Student(28));\n" +
" list.add(new Student(25));\n" +
" }\n" +
"}\n" +
"```\n" +
"\n" +
"对ArrayList集合中的Student对象按照年龄进行排序,下面代码正确的是? ()\n" +
"\n" +
"```java\n" +
"A: Collections.sort(list,(Student a,Student b)->{return a.getAge()-b.getAge();});\n" +
"\n" +
"B: Collections.sort(list,(Student a,Student b)->return a.getAge()-b.getAge(););\n" +
"\n" +
"C: Collections.sort(list,(Student a,Student b)->{return a.age-b.age;});\n" +
"\n" +
"D: Collections.sort(list,(Student a,Student b)->{a.getAge()-b.getAge();});\n" +
"```\n" +
"\n","A");
map.put("使用Lambda表达式创建线程,下面选项错误的是? ()\n" +
"\n" +
"```java\n" +
"A: Runnable r=()->{System.out.println(\"HelloWorld\");}; new Thread(r).start();\n" +
"\n" +
"B: new Thread(()->System.out.println(\"HelloWold\")).start();\n" +
"\n" +
"C: new Thread(()->{System.out.println(\"HelloWorld\");}).start();\n" +
"\n" +
"D: Runnable r=()->{System.out.println(\"HelloWorld\");}; r.start();\n" +
"```\n" +
"\n","D");
map.put("有一个数组Integer[] arr={9,1,5,2,3,8,6,7,9};下面选项可以对数组进行降序排列的是? ()\n" +
"\n" +
"```java\n" +
"A: Arrays.sort(arr, (Integer a,Integer b)->b-a);\n" +
"\n" +
"B: Arrays.sort(arr, (Integer a,Integer b)->a-b);\n" +
"\n" +
"C: Arrays.sort(arr, (a,b)->a-b);\n" +
"\n" +
"D: Arrays.sort(arr, (a,b)->{return a-b;});\n" +
"```\n" +
"\n","A");
map.put("有一个接口如下\n" +
"\n" +
"```java\n" +
"public interface Phone {\n" +
" void call(String message);\n" +
"}\n" +
"```\n" +
"\n" +
"调用call(String message)方法,以下代码错误的是? ()\n" +
"\n" +
"```java\n" +
"A: Phone p=(message) -> System.out.println(message); p.call(\"Hello\");\n" +
"\n" +
"B: Phone p=message -> System.out.println(message); p.call(\"Java\");\n" +
"\n" +
"C: Phone p=message->{return \"Hello\"}; p.call(message);\n" +
"\n" +
"D: Phone p=(message)->{System.out.println(message);}; p.call(\"HeiMa\");\n" +
"```\n" +
"\n","C");
map.put("观察以下代码\n" +
"\n" +
"```java\n" +
"public interface Animal {\n" +
" public abstract void eat(String some);\n" +
"}\n" +
"\n" +
"public class Feeder {\n" +
" public static void feed(Animal a,String some){\n" +
" a.eat(some);\n" +
" }\n" +
"}\n" +
"```\n" +
"\n" +
"下面那个选项能输出\"猫吃鱼\"? ( )\n" +
"\n" +
"```java\n" +
"A: Feeder.feed(new Animal(\"猫吃鱼\"));\n" +
"\n" +
"B: Feeder.feed(Animal()-->\"猫吃鱼\");\n" +
"\n" +
"C: Feeder.feed((some)->System.out.println(\"猫吃鱼\"));\n" +
"\n" +
"D: Feeder.feed(some->System.out.println(some),\"猫吃鱼\");\n" +
"```\n" +
"\n","D");
map.put("下列说法错误的是 : ( )\n" +
"\n" +
"A: Lambda表达式能够延迟执行\n" +
"\n" +
"B: 使用Lambda表达式作为方法参数,其实就是使用函数式接口作为方法参数\n" +
"\n" +
"C: 对于非函数式接口作为方法参数, 也可以用Lambda表达式进行参数传递\n" +
"\n" +
"D: Lambda表达式可以简化某些特定匿名内部类的写法","C");
map.put("下列哪种方式的转换是正确的 : ( )\n" +
"\n" +
"```java\n" +
"A: int[] arr = Stream.of(\"90\",\"80\",\"70\",\"60\").map(Integer::parseInt).toArray(Integer[]::new);\n" +
"\n" +
"B: Integer[] arr = Stream.of(\"90\",\"80\",\"70\",\"60\").toArray(Integer[]::new);\n" +
"\n" +
"C: String[] arr = Stream.of(\"90\",\"80\",\"70\",\"60\").map(Integer::parseInt).toArray(String[]::new);\n" +
"\n" +
"D: Integer[] arr = Stream.of(\"90\",\"80\",\"70\",\"60\").map(Integer::parseInt).toArray(Integer[]::new);\n" +
"```\n" +
"\n","D");
map.put("观察下列代码,求最终结果:( )\n" +
"\n" +
"```java\n" +
"Stream original = Stream.of(\"Hello.java\", \"java编程思想.pdf\", \"IOS开发快速入门.pdf\", \"stream.java\",\"小葵花宝典.txt\",\"如何学好java.txt\");\n" +
"\n" +
"Stream result = original.filter(s -> s.contains(\"java\")).skip(1);\n" +
"\n" +
"System.out.println(result.count());\n" +
"```\n" +
"\n" +
"A: 3\n" +
"\n" +
"B: 4\n" +
"\n" +
"C: 2\n" +
"\n" +
"D: 1","A");
map.put("观察下列代码\n" +
"\n" +
"```java\n" +
"Integer[] sixNums = {1, 2, 3, 4, 5, 6};\n" +
"\n" +
"Integer[] evens = Stream.of(sixNums).filter(n -> n%2 == 0).toArray(Integer[]::new);\n" +
"```\n" +
"\n" +
"请问,得到数组evens中的结果是什么? ( )\n" +
"\n" +
"A: {1,3,5}\n" +
"\n" +
"B: {2,4,6}\n" +
"\n" +
"C: {1,2,3}\n" +
"\n" +
"D: {3,4,5,6}","B");
map.put("下列获取流的方式, 错误的是: ( )\n" +
"\n" +
"```java\n" +
"A: Map map = new HashMap<>(); Stream keyStream = map.keySet().stream();\n" +
"\n" +
"B: Map map = new HashMap<>(); Stream mapStream = map.stream();\n" +
"\n" +
"C: Map map = new HashMap<>(); Stream> entryStream = map.entrySet().stream();\n" +
"\n" +
"D: Map map = new HashMap<>(); Stream valueStream = map.values().stream();\n" +
"```\n" +
"\n","B");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:File类可以根据表示文件路径的字符串创建一个File类对象;\n" +
"\n" +
"B:File类对象表示的文件或文件夹可能存在也可能不存在;\n" +
"\n" +
"C:File类可以使用绝对路径或者相对路径创建文件;\n" +
"D:对象new File(“F:\\\\1.txt”)表示的一定是F盘根目录下的一个文本文件;\n" +
"\n","D");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:File类提供了创建文件和创建文件夹的方法;\n" +
"\n" +
"B:不管路径名有没有后缀,使用createNewFile方法都是创建文件;\n" +
"\n" +
"C:使用File类创建文件的时候,父目录必须存在,否则就会报错;\n" +
"\n" +
"D:使用File类创建文件夹的时候,父目录必须存在,否则就会报错;","D");
map.put("下列说法错误的是:()\n" +
"\n" +
"A. 一个File 对象代表了操作系统中的一个文件或者文件夹\n" +
"B. 可以使用File 对象创建和删除一个文件\n" +
"C. 可以使用File 对象创建和删除一个文件夹\n" +
"D. 当一个File 对象被垃圾回收时,系统上对应的文件或文件夹也被删除\n" +
"\n","D");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:使用File类可以获取硬盘上的所有磁盘盘符;\n" +
"\n" +
"B:使用File类可以获取文件中的数据;\n" +
"\n" +
"C:使用File类可以获取一个文件的字节数;\n" +
"\n" +
"D:使用File类的高级获取方法(listFiles)方法可以获取一个文件夹中的所有直接子文件,包括隐藏文件;","B");
map.put("请问File类中获取文件或者文件夹名字的方法是? 最终结果:( )\n" +
"\n" +
"A: getName\n" +
"\n" +
"B: getFiles\n" +
"\n" +
"C: getDirectory\n" +
"\n" +
"D: isFile","A");
map.put("请问File类中判断一个路径指向的是文件的方法是?最终结果:( )\n" +
"\n" +
"A: isDirectory\n" +
"\n" +
"B: isHidden\n" +
"\n" +
"C: getAbsoluteFile\n" +
"\n" +
"D: isFile","D");
map.put("请问File类中判断一个路径指向的是文件夹的方法是?最终结果:( )\n" +
"\n" +
"A: isAbsolute\n" +
"\n" +
"B: getPath\n" +
"\n" +
"C: getParentFile\n" +
"\n" +
"D: isDirectory\n" +
"\n","D");
map.put("请问以下哪个选项是相对路径?最终结果:( )\n" +
"\n" +
"A: C:\\itheima\\Demo1.java\n" +
"\n" +
"B: day01\\com\\itheima\\day09\\FileDemo.java\n" +
"\n" +
"C: D:\\musics\\x.mp3\n" +
"\n" +
"D: E:\\movies","B");
map.put("关于File对象创建错误的是( )\n" +
"\n" +
"A: File file1 = new File(\"D:\\\\test.txt\");\t \n" +
"\n" +
"B: File file2 = new File(\"D:\\\\test\");\t \n" +
"\n" +
"C: File file3 = new File(\"D:\\\\test\", \"test.txt\");\t \n" +
"\n" +
"D: File file4 = new File(new Object());","D");
map.put("下列File类的方法应用说明正确的是( ) \n" +
"\n" +
"A: getPath() :将此File转换为绝对路径名 字符串。\t \n" +
"\n" +
"B: exists() :此File表示的文件或目录是否实际存在,如果不存在则创建。\n" +
"\n" +
"C: length() :返回由此File表示的文件的字节长度。\t \n" +
"\n" +
"D: isDirectory() :判断此File表示的是否为文件。","C");
map.put("File类型中定义了什么方法来判断一个文件是否存在?( )\n" +
"\n" +
"A: createNewFile\t \n" +
"\n" +
"B: renameTo\t \n" +
"\n" +
"C: delete\t \n" +
"\n" +
"D: exists\t","D");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:抽象路径是不带磁盘盘符的路径;\n" +
"\n" +
"B:绝对路径是带磁盘盘符的路径;\n" +
"\n" +
"C:要获取一个文件夹及其所有子文件夹中的内容,可以使用递归实现;\n" +
"\n" +
"D:递归就是函数中直接或间接的调用函数自身;递归效率比循环更高;","D");
map.put("递归是什么含义?( )\n" +
"\n" +
"A: 就是调用方法\n" +
"\n" +
"B: 递归就是方法中调用自身\n" +
"\n" +
"C: 通过对象调用方法\n" +
"\n" +
"D: 无限递归次数不限","B");
map.put("关于递归的描述正确的是(多选) \n" +
"\n" +
"A: 是一种直接或间接地调用自身的算法\t \n" +
"\n" +
"B: 使程序变得简洁\t \n" +
"\n" +
"C: 递归的次数对程序的运行没有任何影响\t \n" +
"\n" +
"D: 必须要有一个出口","ABD");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:IO流是用来将数据从计算机内存和内存之外进行交换的;\n" +
"\n" +
"B:输入流是将数据从内存外读进内存的;\n" +
"\n" +
"C:输出流是将数据从内存里写出去的;\n" +
"\n" +
"D:IO流只能读写文件数据;","D");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:按照数据流动方向,IO可分为输入流和输出流;\n" +
"\n" +
"B:按照数据读写单位,IO可分为字节流和字符流;\n" +
"\n" +
"C:字节流可以读写任意类型的文件,因为所有文件底层都是0101这样的字节数据;\n" +
"\n" +
"D:字符流可以读写文本文件和图片文件;","D");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:InputStream是所有字节输入流的最高父类;\n" +
"\n" +
"B:InputStream类的对象可以从文件中读取字节数据;\n" +
"\n" +
"C:FileInputstream类是用来从文件中读取字节数据的;\n" +
"\n" +
"D:OutputStream类是所有字节输出流的最高父类;","B");
map.put("观察下列代码\n" +
"\n" +
"```java\n" +
"public static void main(String[] args) throws Exception {\n" +
" FileOutputStream fos = new FileOutputStream(\"测试.txt\");\n" +
" fos.write(97);\n" +
" fos.close();\n" +
"}\n" +
"```\n" +
"\n" +
"请问,文件当中显示的结果是什么? ( )\n" +
"\n" +
"A: 97\n" +
"\n" +
"B: 9\n" +
"\n" +
"C: A\n" +
"\n" +
"D: a","D");
map.put("观察下列代码\n" +
"\n" +
"```java\n" +
"public static void main(String[] args) throws Exception {\n" +
" FileOutputStream fos = new FileOutputStream(\"测试.txt\");\n" +
" fos.write('g');\n" +
" fos.close();\n" +
" fos.write('d');\n" +
" fos.close();\n" +
"}\n" +
"```\n" +
"\n" +
"请问,文件当中显示的结果是什么?( )\n" +
"\n" +
"A: 出现异常,文件无内容\n" +
"\n" +
"B: 出现异常,输出流已关闭不能写入数据,但文件里的内容是g\n" +
"\n" +
"C: gd\n" +
"\n" +
"D: d","B");
map.put("观察下列代码\n" +
"\n" +
"```java\n" +
"public static void main(String[] args) throws Exception {\n" +
" FileInputStream fis = new FileInputStream(\"测试.txt\");\n" +
" int temp;\n" +
" while(需要补充的代码){\n" +
" System.out.println(temp);\n" +
" }\n" +
" fis.close();\n" +
"}\n" +
"```\n" +
"\n" +
"请选择需要填补的代码 ( )\n" +
"\n" +
"A: (temp=fis.read(temp))!=-1\n" +
"\n" +
"B: (fis.read(temp))!=-1\n" +
"\n" +
"C: (temp=fis.read())!=-1\n" +
"\n" +
"D: fis.read()!=-1","C");
map.put("\"测试.txt\"当中内容如下:\n" +
"\n" +
"abc\n" +
"\n" +
"观察下面代码\n" +
"\n" +
"```java\n" +
"public static void main(String[] args) throws Exception {\n" +
" FileInputStream fis = new FileInputStream(\"测试.txt\");\n" +
" int temp;\n" +
" while((temp=fis.read())!=-1){\n" +
" System.out.print(temp);\n" +
" }\n" +
" fis.close();\n" +
"}\n" +
"```\n" +
"\n" +
"运行代码后,控制台显示结果是?( )\n" +
"\n" +
"A: abc\n" +
"\n" +
"B: a\n" +
"\n" +
"C: 656667\n" +
"\n" +
"D: 979899","D");
map.put("在“测试文件.txt”中,有如下数据:\n" +
"\n" +
"abc\n" +
"\n" +
"请分析,以下代码执行后,文件中的数据为: ( )\n" +
"\n" +
"```java\n" +
"public static void main(String[] args) throws Exception {\n" +
" FileInputStream fis = new FileInputStream(\"测试文件.txt\");\n" +
" FileOutputStream fos = new FileOutputStream(\"测试文件.txt\");\n" +
" int temp = 0;\n" +
" while((temp = fis.read()) != -1){\n" +
" fos.write(temp);\n" +
" }\n" +
" fis.close();\n" +
" fos.close();\n" +
"}\n" +
"```\n" +
"\n" +
"A: abcabc\n" +
"\n" +
"B: abc\n" +
"\n" +
"C: 没有数据\n" +
"\n" +
"D: 979899","C");
map.put("在Java的IO操作中,( )方法可以用来刷新流的缓冲(多选)。\n" +
"\n" +
"A: void release( )\t \n" +
"\n" +
"B: void close( )\t \n" +
"\n" +
"C: void remove( )\t \n" +
"\n" +
"D: void flush( )\n" +
"\n","BD");
map.put("使用Java IO流实现对文本文件的读写过程中,需要处理下列( )异常。 \n" +
"\n" +
"A: NullPointerException\t \n" +
"\n" +
"B: IOException\t \n" +
"\n" +
"C: SQLException\t \n" +
"\n" +
"D: RemoteException","B");
map.put("想要在 测试文件 当中显示数据是 97 \n" +
"\n" +
"请问在 下面代码 fw.write() 的括号当中,应该选择哪一项? ( )\n" +
"\n" +
"```java\n" +
"public static void main(String[] args) throws Exception {\n" +
" FileWriter fw = new FileWriter(\"测试文件.txt\");\n" +
" fw.write(需要填写代码);\n" +
" fw.close();\n" +
"}\n" +
"```\n" +
"\n" +
"A: 97\n" +
"\n" +
"B: 'a'\n" +
"\n" +
"C: 'A'\n" +
"\n" +
"D: \"97\"","D");
map.put("想要在 测试文件 当中显示数据是 helloworld 其中hello是第一行,world是第二行。在Windows操作系统中有效\n" +
"\n" +
"代码如下:\n" +
"\n" +
"```java\n" +
"public static void main(String[] args) throws Exception {\n" +
" FileWriter fw = new FileWriter(\"测试文件.txt\");\n" +
" fw.write(\"需要填写代码\");\n" +
" fw.close();\n" +
"}\n" +
"```\n" +
"\n" +
"请问:在需要填写代码处,应该如下填写代码? ( )\n" +
"\n" +
"A: hello\\n\\rworld\n" +
"\n" +
"B: hello\\dworld\n" +
"\n" +
"C: hello\\rworld\n" +
"\n" +
"D: hello\\r\\nworld\n" +
"\n","D");
map.put("在Java中,下列关于读写文件的描述错误的是( )。 \n" +
"\n" +
"A: Reader类的read()方法用来从源中读取一个字符的数据\t \n" +
"\n" +
"B: Reader类的read(int n )方法用来从源中读取一个字符的数据\t \n" +
"\n" +
"C: Writer类的write(int n)方法用来向输出流写入单个字符\t \n" +
"\n" +
"D: Writer类的write(String str)方法用来向输出流写入一个字符串","B");
map.put("在测试文件当中,数据如下:\n" +
"\n" +
"ABC\n" +
"\n" +
"下面代码执行之后\n" +
"\n" +
"```java\n" +
"public static void main(String[] args) throws Exception {\n" +
" FileReader fr = new FileReader(\"测试文件.txt\");\n" +
" int temp;\n" +
" while((temp=fr.read())!=-1){\n" +
" System.out.print(temp);\n" +
" }\n" +
" fr.close();\n" +
"}\n" +
"```\n" +
"\n" +
"请问控制台显示结果是?( )\n" +
"\n" +
"A: ABC\n" +
"\n" +
"B: abc\n" +
"\n" +
"C: 656667\n" +
"\n" +
"D: 979899","C");
map.put("在测试文件当中,ABC在一行,数据如下: \n" +
"\n" +
"ABC\n" +
"\n" +
"下面代码执行之后\n" +
"\n" +
"```java\n" +
"public static void main(String[] args) throws Exception {\n" +
"\n" +
" FileReader fr = new FileReader(\"测试文件.txt\");\n" +
" int ch;\n" +
" while(true){\n" +
" ch=fr.read();\n" +
" if(ch==-1){\n" +
" break;\n" +
" }\n" +
" System.out.print((char)ch);\n" +
" }\n" +
" fr.close();\n" +
"}\n" +
"```\n" +
"\n" +
"请问控制台显示结果是? ( )\n" +
"\n" +
"A: ABC\n" +
"\n" +
"B: ab\n" +
"\n" +
"C: 979899\n" +
"\n" +
"D: 666768","A");
map.put("在测试文件当中,数据如下:\n" +
"\n" +
"abcdefgh\n" +
"\n" +
"完成文件一次读取一个字符数组的操作\n" +
"\n" +
"```java\n" +
"public static void main(String[] args) throws Exception {\n" +
"\n" +
" FileReader fr = new FileReader(\"测试文件.txt\");\n" +
" int len;\n" +
" char[] chArr = new char[3];\n" +
" while(填补代码){\n" +
" System.out.print(new String(chArr,0,len));\n" +
" }\n" +
" fr.close();\n" +
"}\n" +
"```\n" +
"\n" +
"请选择正确的填补代码的选项? ( )\n" +
"\n" +
"A: (len = fr.read(chArr))!=-1\n" +
"\n" +
"B: (len = fr.read())!=-1\n" +
"\n" +
"C: (fr.read())!=-1\n" +
"\n" +
"D: (chArr=fr.read(len))!=-1","A");
map.put("在测试文件当中,数据如下:\n" +
"\n" +
"abcdefgh\n" +
"\n" +
"完成文件一次读取一个字符数组的操作\n" +
"\n" +
"```java\n" +
"public static void main(String[] args) throws Exception {\n" +
" FileReader fr = new FileReader(\"测试文件.txt\");\n" +
" int len;\n" +
" char[] chArr = new char[3];\n" +
" while((len = fr.read(chArr))!=-1){\n" +
" System.out.print(new String(chArr,len,0));\n" +
" }\n" +
" fr.close();\n" +
"}\n" +
"```\n" +
"\n" +
"请选择运行的结果? ( )\n" +
"\n" +
"A: abcdefgh\n" +
"\n" +
"B: abc\n" +
"\n" +
"C: 无结果\n" +
"\n" +
"D: 979899100101102103104","C");
map.put("已知在项目的模块itcast下存在一个文件person.txt,里面的内容如下:\n" +
"\n" +
"\u200B\t王五=南京\n" +
"\n" +
"\u200B\t张三=上海\n" +
"\n" +
"\u200B\t李四=北京\n" +
"\n" +
"观察下列代码,最终结果是:( )\n" +
"\n" +
"```java\n" +
"Properties prop = new Properties();\n" +
"prop.load(new FileReader(\"itcast\\\\person.txt\"));\n" +
"Set keys = prop.stringPropertyNames();\n" +
"for (Iterator it = keys.iterator(); it.hasNext();) {\n" +
"\tString key = it.next();\n" +
"\tString value = prop.getProperty(key);\n" +
"\tSystem.out.println(key+\"---\"+value);\n" +
"}\n" +
"```\n" +
"\n" +
"A: 没有任何结果\n" +
"\n" +
"B: 报异常\n" +
"\n" +
"C: 李四---北京 张三---上海 王五---南京\n" +
"\n" +
"D: 李四---北京 张三---上海","C");
map.put("已知存在一个文件:D:\\user.txt,里面的内容如下:\n" +
"\n" +
"username=zhangsan\n" +
"\n" +
"password=123\n" +
"\n" +
"观察下列代码,最终结果是:( )\n" +
"\n" +
"```java\n" +
"Properties prop = new Properties();\n" +
"prop.load(new FileReader(\"D:\\\\user.txt\"));\n" +
"String username = prop.getProperty(\"username\");\n" +
"String password = prop.getProperty(\"password\");\n" +
"if(\"zhangsan\".equals(username)&&\"123\".equals(password)){\n" +
" System.out.println(\"登录成功\");\n" +
"}else{\n" +
" System.out.println(\"用户名或者密码错误\");\n" +
"}\n" +
"```\n" +
"\n" +
"A: 登录成功\n" +
"\n" +
"B: 用户名或者密码错误\n" +
"\n" +
"C: 不打印任何内容\n" +
"\n" +
"D: 程序无法正常运行\n" +
"\n","A");
map.put("下列说法错误的是:\n" +
"\n" +
"A:打印流不会抛出IO异常;\n" +
"\n" +
"B:Properties主要被用来操作内容是键值对的配置文件;\n" +
"\n" +
"C:Properties本质上是一个Map集合;所以一般都通过Map接口中定义的方法来操作Properties对象;\n" +
"\n" +
"D:Properties不能直接读写文件,所以使用Properties时需要提供相应的IO流;\n" +
"\n","C");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:缓冲字节流底层也是使用普通的字节流读写数据的;\n" +
"\n" +
"B:缓冲字节流底层有一个数组,用于缓存要读写的数据;\n" +
"\n" +
"C:缓冲字节流读写数据时不是直接操作硬盘的,而是操作缓存数组的,因为直接操作内存,所以速度快;\n" +
"\n" +
"D:缓冲字节流写数据时,先将数据写到缓存数组中;只有到关闭流时才将数据写出到硬盘上;","D");
map.put("已知在项目的模块itcast下存在123.txt文件,文件中具有如下数据:\n" +
"\n" +
"abc你好\n" +
"\n" +
"观察下列代码,求最终结果:( )\n" +
"\n" +
"```java\n" +
"BufferedInputStream bufin = new BufferedInputStream(new FileInputStream(\"itcast\\\\123.txt\"));//itcast表示模块名\n" +
"byte[] b = new byte[4];\n" +
"int len = 0;\n" +
"while ((len = bufin.read(b)) != -1) {System.out.println(new String(b));}\n" +
"bufin.close();\n" +
"```\n" +
"\n" +
"A: abc你好\n" +
"\n" +
"B: abc你\n" +
"\n" +
"C: 报异常\n" +
"\n" +
"D: 在控制台会看到乱码","D");
map.put("已知在项目的模块itcast下存在123.txt文件,文件中具有如下数据:\n" +
"\n" +
"ab\n" +
"\n" +
"观察下列代码\n" +
"\n" +
"```java\n" +
"BufferedInputStream buf = new BufferedInputStream(new FileInputStream(\"itcast\\\\123.txt\"));//itcast表示模块名\n" +
"int b1 = buf.read();System.out.println(b1);\n" +
"int b2 = buf.read();System.out.println(b2);\n" +
"int b3 = buf.read();System.out.println(b3);\n" +
"buf.close();\n" +
"```\n" +
"\n" +
"请问,在控制台得到的结果是什么? ( )\n" +
"\n" +
"A: a b -1\n" +
"\n" +
"B: 97 98 -1\n" +
"\n" +
"C: a b a\n" +
"\n" +
"D: 97 98","B");
map.put("已知在项目目录下有“itcast”文件夹,观察下列代码,执行后产生的结果是:\n" +
"\n" +
"```java\n" +
"FileOutputStream fo = new FileOutputStream(\"itcast\\\\out.txt\");\n" +
"fo.write(\"hello 黑马程序员\".getBytes());\n" +
"fo.close();\n" +
"fo.write(\"hello 传智播客\".getBytes());\n" +
"```\n" +
"\n" +
"A: 不会生成任何文件,代码报出异常,因为在项目的模块itcast下找不到相应的\"out.txt\"\n" +
"\n" +
"B: 在项目的模块itcast下会生成一个out.txt文件,里面的内容是:hello 黑马程序员hello 传智播客\n" +
"\n" +
"C: 在项目的模块itcast下会生成一个out.txt文件,里面的内容是:hello 黑马程序员。但是会报异常:Stream Closed\n" +
"\n" +
"D: 在项目的模块itcast下会生成一个out.txt文件,里面的内容是:hello 传智播客。但是会报异常:Stream Closed","C");
map.put("已知在项目的模块itcast下存在copy.txt文件,文件中具有如下数据:\n" +
"\n" +
"黑马程序员\n" +
"\n" +
"观察下列代码,求最终结果:( )\n" +
"\n" +
"```java\n" +
"BufferedReader br = new BufferedReader(new FileReader(\"itcast\\\\copy.txt\"));\n" +
"BufferedWriter bw = new BufferedWriter(new FileWriter(\"itcast\\\\copy.txt\"));\n" +
"String line=null;\n" +
"while((line=br.readLine())!=null){bw.write(line);}\n" +
"bw.close();\n" +
"br.close();\n" +
"```\n" +
"\n" +
"A: 黑马程序员\n" +
"\n" +
"B: 报异常\n" +
"\n" +
"C: 项目的模块itcast下的copy.txt文件没有任何内容\n" +
"\n" +
"D: 黑马程序员黑马程序员","C");
map.put("当前项目路径下存在一个itcast目录,观察下列代码,求最终结果:( )\n" +
"\n" +
"```java\n" +
"BufferedWriter bw = new BufferedWriter(new FileWriter(\"itcast\\\\bw.txt\"));\n" +
"bw.write(\"传智学院\");\n" +
"bw.write(\"传智播客\");\n" +
"bw.newLine();\n" +
"bw.write(\"黑马程序员\");\n" +
"bw.close();\n" +
"```\n" +
"\n" +
"A: 报找不到文件异常,因为bw.txt文件不存在\n" +
"\n" +
"B: 在项目的模块itcast下创建一个bw.txt文件,但是文件中没有任何内容\n" +
"\n" +
"C: 在项目的模块itcast下创建一个bw.txt文件,文件中内容是:\n" +
"\n" +
"D: 在项目的模块itcast下创建一个bw.txt文件,文件中内容是:传智学院传智播客[这里换行]黑马程序员\n" +
"\n","D");
map.put("假设当前项目根目录下test.txt文件内容为www.itcast.cn;以下代码运行后test.txt文件中的内容是( )。\n" +
"\n" +
"```java\n" +
"public class TestBuffered {\n" +
"\tpublic static void main(String[] args) throws IOException {\n" +
"\t\tBufferedReader br = new BufferedReader(new FileReader(\"test.txt\"));\n" +
" BufferedWriter bw = new BufferedWriter(new FileWriter(\"test.txt\"));\n" +
" String str = br.readLine();\n" +
" if(str !=null){\n" +
"\t\t\tbw.write(“官网:”+str);\n" +
"\t\t\tbw.flush();\n" +
" }\n" +
" br.close();\n" +
" bw.close(); \n" +
"\t}\n" +
"}\n" +
"```\n" +
"\n" +
"A: www.itcast.cn\t \n" +
"\n" +
"B: 文件内容为空\t \n" +
"\n" +
"C: 官网:www.itcast.cn\t \n" +
"\n" +
"D: 代码报错;","B");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:转换流是字节流和字符流之间转换的桥梁;\n" +
"\n" +
"B:输入转换流可以将输入字节流转换为输入字符流;\n" +
"\n" +
"C:输出转换流可以将输出字符流转换为输出字节流;\n" +
"D:转换流可以直接读写文件;","D");
map.put("以下关于编码表阐述错误的是:( )\n" +
"\n" +
"A: 编码表可以将计算机所熟知的二进制和我们所熟悉的字符之间进行转换\n" +
"\n" +
"B: 无论什么编码表都兼容ASCII码表\n" +
"\n" +
"C: ISO-8859-1编码表适用于欧美国家\n" +
"\n" +
"D: ASCII码表支持中文","D");
map.put("以下关于编码表阐述错误的是:( )\n" +
"\n" +
"A: 在UTF-8编码表中中文占2个字节\n" +
"\n" +
"B: 乱码产生的原因是编码和解码使用的编码表不一致导致的\n" +
"\n" +
"C: 在ASCII码表中b的编码值是98\n" +
"\n" +
"D: 将存储在计算机中的二进制数按照某种规则解析显示出来,称为解码","A");
map.put("( )是转换流,可以将字节流转换成字符流,是字节流通往字符流之间的桥梁\n" +
"\n" +
"A: InputStreamReader\t \n" +
"\n" +
"B: FileWriter\t \n" +
"\n" +
"C: BufferedWriter\t \n" +
"\n" +
"D: OutputStreamWriter\t","A");
map.put("已知在硬盘: F:\\\\4.txt 文件中保存字符串数据:\"你好\" 。\n" +
"\n" +
"注意:\n" +
"\n" +
"1)该文件以GBK编码保存的。\n" +
"\n" +
"2)idea工作环境默认编码方式是UTF-8。\n" +
"\n" +
"观察下列代码,求最终结果:( )\n" +
"\n" +
"```java\n" +
"InputStreamReader isr = new InputStreamReader(new FileInputStream(\"F:\\\\4.txt\"));\n" +
"int read;\n" +
"while ((read = isr.read()) != -1) {System.out.print((char)read);}\n" +
"isr.close();\n" +
"```\n" +
"\n" +
"A: 你好\n" +
"\n" +
"B: 没有结果\n" +
"\n" +
"C: 报异常\n" +
"\n" +
"D: 乱码","D");
map.put("已知在硬盘: D:\\\\123.txt 文件中保存字符串数据:\"传智学院\" 。\n" +
"\n" +
"注意:\n" +
"\n" +
"1)该文件以GBK编码保存的。\n" +
"\n" +
"2)idea工作环境默认编码方式是UTF-8。\n" +
"\n" +
"观察下列代码,求最终结果:( )\n" +
"\n" +
"```java\n" +
"InputStreamReader isr = new InputStreamReader(new FileInputStream(\"D:\\\\123.txt\"),\"GBK\");\n" +
"int read;\n" +
"while ((read = isr.read()) != -1) { System.out.print((char)read);}\n" +
"isr.close();\n" +
"```\n" +
"\n" +
"A: 传智学院\n" +
"\n" +
"B: 乱码\n" +
"\n" +
"C: 报异常\n" +
"\n" +
"D: 没有结果","A");
map.put("已知idea工作环境默认编码方式是UTF-8。\n" +
"\n" +
"观察下列代码,以下说法正确的是:( )\n" +
"\n" +
"```java\n" +
"OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(\"E:\\\\out.txt\"));\n" +
"osw.write(\"你好\"); \n" +
"osw.close();\n" +
"```\n" +
"\n" +
"A: 会在E盘位置生成一个out.txt文件,文件中的内容是乱码\n" +
"\n" +
"B: 不会在E盘位置生成一个out.txt文件\n" +
"\n" +
"C: 会在E盘位置生成一个out.txt文件,文件中的内容是你好,并且文件大小是4个字节\n" +
"\n" +
"D: 会在E盘位置生成一个out.txt文件,文件中的内容是你好,并且文件大小是6个字节\n" +
"\n","D");
map.put("已知在硬盘: F:\\\\4.txt 文件中保存字符串数据:\n" +
"\n" +
"传智播客\n" +
"\n" +
"黑马程序员\n" +
"\n" +
"酷丁鱼\n" +
"\n" +
"传智学院\n" +
"\n" +
"注意:\n" +
"\n" +
"\u200B\t1)该文件以GBK编码保存的。\n" +
"\n" +
"\u200B\t2)idea工作环境默认编码方式是UTF-8。\n" +
"\n" +
"观察下列代码,以下说法正确的是:( )\n" +
"\n" +
"```java\n" +
"InputStreamReader isr = new InputStreamReader(new FileInputStream(\"F:\\\\4.txt\"),\"GBK\");\n" +
"OutputStreamWriter w = new OutputStreamWriter(new FileOutputStream(\"F:\\\\3.txt\"),\"utf8\");\n" +
"char[] buffer = new char[1024];\n" +
"int len = -1;\n" +
"while((len = isr.read(buffer)) != -1){w.write(buffer, 0, len);}\n" +
"isr.close();\n" +
"w.close();\n" +
"```\n" +
"\n" +
"A: 当运行程序后,会在F盘位置生成一个3.txt文件,文件中的内容是乱码\n" +
"\n" +
"B: 当运行程序后,会在F盘位置生成一个3.txt文件,文件中的内容是: \n" +
"\n" +
"\u200B\t传智播客\n" +
"\u200B\t黑马程序员\n" +
"\u200B\t酷丁鱼\n" +
"\u200B\t传智学院\n" +
"\n" +
"C: 当运行程序后,会在F盘位置生成一个3.txt文件,该文件编码方式是gbk\n" +
"\n" +
"D: 当运行程序后,会报找不到文件异常\n" +
"\n","B");
map.put("序列化流\n" +
"\n" +
"### 题目1(加强训练)\n" +
"\n" +
"下列说法错误的是:()\n" +
"\n" +
"A:序列化是将复杂的数据(如对象)转换为二进制数据输出;\n" +
"\n" +
"B:反序列化是将经过序列化得到的二进制数据再转换回复杂数据(如对象);\n" +
"\n" +
"C:序列化保存对象时,静态成员变量的值不能被序列化保存;\n" +
"\n" +
"D:反序列化时,类必须提供无参构造函数;","D");
map.put("关于序列化流的描述正确的是?( )\n" +
"\n" +
"A: 一个类只要实现了java.io.Serializable接口,该类对应的对象就可以实现序列化\n" +
"\n" +
"B: ObjectOutputStream流是将内容写入到Object对象中\t \n" +
"\n" +
"C: ObjectInputStream流是读取Object对象里的内容\t \t \n" +
"\n" +
"D: ObjectInputStream是从文件中读取一个对象出来,读出来是Object类型的,需要进行强制类型转换","D");
map.put("网络编程三要素不包括:()\n" +
"\n" +
"A:IP\n" +
"\n" +
"B:端口\n" +
"\n" +
"C:协议\n" +
"\n" +
"D:域名\n" +
"\n","D");
map.put("UDP协议的特点不包括:()\n" +
"\n" +
"A:面向无连接,不可靠;\n" +
"\n" +
"B:传输数据大小有限制,每次最多64kb;\n" +
"\n" +
"C:效率高;\n" +
"\n" +
"D:数据接收方必须存在才能发送数据;\n" +
"\n","D");
map.put("TCP协议的特点不包括:()\n" +
"\n" +
"A:面向有连接,安全可靠;\n" +
"\n" +
"B:数据传输大小没有限制;\n" +
"\n" +
"C:需要经过三次握手,确认对方存在才能建立连接,效率比UDP协议更低;\n" +
"\n" +
"D:一般在传输文件时不能使用TCP协议,因为TCP协议效率低;","D");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:使用UDP协议发送数据,需要将数据封装到一个数据报包(DatagramPacket)对象中;\n" +
"\n" +
"B:UDP发送方的数据报包对象就像一个快递包裹,包含了发送的数据、接收方的ip和接收方的端口;\n" +
"\n" +
"C:UDP接收方接受的数据,也要使用一个数据报包对象封装,应该给这个数据报包对象传递一个数组来保存接收的数据;\n" +
"\n" +
"D:UDP协议发送数据,发送多个数据报包时,接收方是按照发送的顺序接受的;","D");
map.put("下列说法错误的是:()\n" +
"\n" +
"A:使用TCP协议通信时,首先发起连接请求的一方叫做客户端,被动接受请求的一方叫做服务器;\n" +
"\n" +
"B:TCP协议的服务器一方使用ServerSocket类的对象表示,创建这个类的对象时需要指定服务器监听的端口;\n" +
"\n" +
"C: TCP服务器启动后,没有客户端连接,就会一直阻塞;当有客户连接到达时,就会获取一个表示这个连接的Socket对象,然后通过这个Socket对象和客户端通信;\n" +
"\n" +
"D:TCP服务器在处理完一个客户端请求之前,不能接受其他的客户端请求;","D");
map.put("观察下列代码,最终结果是:( )\n" +
"\n" +
"客户端代码:\n" +
"\n" +
"```java\n" +
"Socket s = new Socket(\"127.0.0.1\", 10000);\n" +
"\n" +
"OutputStream os = s.getOutputStream();\n" +
"\n" +
"os.write(\"hello,TCP,我来了\".getBytes());\n" +
"\n" +
"s.close();\n" +
"```\n" +
"\n" +
"服务端代码:\n" +
"\n" +
"```java\n" +
"ServerSocket serverSocket = new ServerSocket(9999);\n" +
"\n" +
"Socket socket = serverSocket.accept();\n" +
"\n" +
"InputStream is = socket.getInputStream();\n" +
"\n" +
"byte[] buf=new byte[1024];\n" +
"\n" +
"int len=0;\n" +
"\n" +
"while((len=is.read(buf))!=-1){System.out.println(new String(buf,0,len));}\n" +
"```\n" +
"\n" +
"A: hello,TCP,我来了\n" +
"\n" +
"B: 客户端报异常,java.net.ConnectException: Connection refused\n" +
"\n" +
"C: 报连接超时异常\n" +
"\n" +
"D: 没有输出任何内容","B");
map.put("以下关于TCP传输协议描述错误的是:( )\n" +
"\n" +
"A: TCP需要先建立连接,因此,服务端必须先存在,客户端才能正常执行\n" +
"\n" +
"B: 对于TCP传输协议,服务端不需要使用客户端Socket\n" +
"\n" +
"C: 多个客户端可以访问一个服务端\n" +
"\n" +
"D: 客户端之间是不能相互访问的","B");
map.put("以下关于TCP传输协议下文件的上传描述错误的是: ( )\n" +
"\n" +
"A: 文件上传,服务端需要获取客户端的Socket,然后使用获取的Socket向通道中写反馈信息\n" +
"\n" +
"B: 如果客户端已经上传完毕,那么需要使用Socket类中的shutdownOutput()方法向通道中写结束标记\n" +
"\n" +
"C: 在服务端需要使用accept()方法来侦听并获取客户端套接字对象\n" +
"\n" +
"D: 客户端不用知道服务端端口号也能访问服务端","D");
map.put("以下关于CS架构说法错误的是:( )\n" +
"\n" +
"A: 全称为Client/Server结构,是指客户端和服务器结构\n" +
"\n" +
"B: 可以把一些运算放在客户端的电脑上运行。降低服务器的压力\n" +
"\n" +
"C: 开发软件的时候,程序员需要开发2套软件,一个是给用户使用的客户端程序,一个是给服务器运行服务端程序\n" +
"\n" +
"D: 开发周期短,维护成本低","D");
map.put("以下描述不正确的是( )\n" +
"\n" +
"A: TCP是面向连接的\t \n" +
"\n" +
"B: TCP可以保证链接的可靠\t \n" +
"\n" +
"C: UDP是安全的\t \n" +
"\n" +
"D: UDP传输速度比TCP快\t","C");
map.put("以下描述错误的有(多选)( )\n" +
"\n" +
"A: TCP要求系统资源较多,UDP较少\t \n" +
"\n" +
"B: TCP保证数据正确性,UDP可能丢包\t \n" +
"\n" +
"C: TCP和UDP均为面向连接的\t \n" +
"\n" +
"D: TCP和UDP在传输数据前需要先进行三次握手\t \n" +
"\n" +
"E: TCP保证链接可靠,UDP不保证\t","CD");
map.put("以下哪个方法是ServerSocket类用于接收来自客户端请求:\n" +
"\n" +
"A: receive()\n" +
"\n" +
"B:accept()\n" +
"\n" +
"C: set()\n" +
"\n" +
"D: send()","B");
map.put("假定Tester 类有如下test方法:\n" +
"public int test(int p1, Integer p2){}\n" +
"以下哪段代码能正确地动态调用一个Tester 对象的test方法?()\n" +
"\n" +
"```java\n" +
"A.\n" +
"Class classType=Tester.class;\n" +
"Object tester=classType.newInstance();\n" +
"Method addMethod=classType.getMethod(\"test\",new Class[]{int.class,int.class});\n" +
"Object result=addMethod.invoke(tester,new Object[]{new Integer(100),new Integer(200)});\n" +
"B.\n" +
"Class classType=Tester.class;\n" +
"Object tester=classType.newInstance();\n" +
"Method addMethod=classType.getMethod(\"test\",new Class[]{int.class,int.class});\n" +
"int result=addMethod.invoke(tester,new Object[]{new Integer(100),new Integer(200)});\n" +
"C.\n" +
"Class classType=Tester.class;\n" +
"Object tester=classType.newInstance();\n" +
"Method addMethod=classType.getMethod(\"test\",new Class[]{int.class,Integer.class});\n" +
"Object result=addMethod.invoke(tester,new Object[]{new Integer(100),new Integer(200)});\n" +
"D.\n" +
"Class classType=Tester.class;\n" +
"Object tester=classType.newInstance();\n" +
"Method addMethod=classType.getMethod(\"test\",new Class[]{int.class,Integer.class});\n" +
"Integer result=addMethod.invoke(tester,new Object[]{new Integer(100),new Integer(200)});\n" +
"```\n" +
"\n","C");
map.put("下列关于通过反射方式获取方法并执行的过程说法错误的是()\n" +
"\n" +
"A、通过Class.getMethod(方法名,参数类型列表)的方式获取该类的公开方法\n" +
"\n" +
"B、通过Class.getDeclaredMethod(方法名,参数类型列表)获取该类的非公开方法\n" +
"\n" +
"C、通过对象名.方法名(参数列表)的方式调用该方法\n" +
"D、通过invoke(对象名,参数列表)方法来执行一个方法","C");
map.put("使用反射获取一个类的成员变量,下列说法正确的是:()\n" +
"\n" +
"A、获取一个成员变量,需要知道变量名;\n" +
"\n" +
"B、只能获取类中的私有成员变量\n" +
"\n" +
"C、只能获取类中公开的成员变量\n" +
"D、要获取类中私有成员变量,必须先调用这个类的setAccessible(true);\n" +
"\n","A");
map.put("执行如下代码控制台输出的是( )\n" +
"\n" +
"```\n" +
"package cn.he.day13;\n" +
"\n" +
"public class Student {\n" +
" private String name;\n" +
"\n" +
" public Student(String name) {\n" +
" this.name = name;\n" +
" }\n" +
"\n" +
" public static void main(String[] args) {\n" +
" Student yang = new Student(\"yangyang\");\n" +
" Class extends Student> aClass = yang.getClass();\n" +
" System.out.println(aClass.getName());\n" +
" }\n" +
"}\n" +
"```\n" +
"\n" +
"A: yqw\n" +
"\n" +
"B: Student\n" +
"\n" +
"C: cn.he.day13.Student\n" +
"\n" +
"D: null","C");
map.put("下面获取String类的字节码对象正确的是(多选)( )\n" +
"\n" +
"A: Class c = String.class;\n" +
"\n" +
"B: Class c = new String().getClass();\n" +
"\n" +
"C: Class c = Class.forName(\"java.lang.String\");\n" +
"\n" +
"D: Class c = Class.forName(\"String\");","ABC");
map.put("下面说法正确的是(多选)( )\n" +
"\n" +
"A: Constructor getConstructor() 只能获得public修饰的构造方法,没有对应方法会抛异常\n" +
"\n" +
"B: Constructor getConstructor() 只能获得public修饰的构造方法,没有对应方法不会抛异常\n" +
"\n" +
"C: Constructor[] getDeclaredConstructors()只能获得public修饰的构造方法,没有对应方法会抛异常\n" +
"\n" +
"D: Constructor getDeclaredConstructor()包括private修饰的构造方法造方法,没有对应方法会抛异常\n" +
"\n","AD");
map.put("关于 Method的 Object invoke(Object obj, Object... args)方法说法正确的是(多选)()\n" +
"\n" +
"A: 此方法不可以执行private修饰的方法\n" +
"\n" +
"B: 此方法可以执行私有方法,但是要先调用void setAccessible(true)\n" +
"\n" +
"C: 参数一是被执行方法的对象,参数二是方法参数值\n" +
"\n" +
"D: 参数一是方法名,参数二是方法参数值","BC");
map.put("关于自定义注解的说法正确的是()\n" +
"\n" +
"A: 当注解中只有一个属性且名称是value,在使用注解时给value属性赋值不能直接给属性值\n" +
"\n" +
"B: 如果注解中除了value属性还有其他属性,且至少有一个属性没有默认值,则在使用注解给属性赋值时,value属性名可以省略\n" +
"\n" +
"C: 如果属性有默认值,则使用注解的时候,这个属性可以不用赋值\n" +
"\n" +
"D: 属性可以是任意数据类型,和一维数组","C");
map.put("下面说法正确的是(多选)()\n" +
"\n" +
"A: @Target 指明此注解用在哪个位置 可选参数值在枚举类ElemenetType\n" +
"\n" +
"B: @Target 指明此注解用在哪个位置 可选参数值在枚举类RetentionPolicy\n" +
"\n" +
"C: @Retention 定义该注解的生命周期可选的参数值在枚举类型RetentionPolicy\n" +
"\n" +
"D: @Retention 定义该注解的生命周期可选的参数值在枚举类型ElemenetType","AC");
map.put("一个字符串由三个0到9的数字字符组成,第一个和第三个一样,匹配规则正确的是:()\n" +
"\n" +
"A:”\\d\\d\\d”\n" +
"\n" +
"B:”\\d{3}”\n" +
"\n" +
"C:”(\\d)\\d\\1”\n" +
"\n" +
"D:”[\\d\\d\\d]”","C");
map.put("符合正则表达式\"[12]|[34]\"的匹配规则的字符串是:()\n" +
"\n" +
"A:”12”\n" +
"\n" +
"B:”34”\n" +
"\n" +
"C:”13”\n" +
"\n" +
"D:”4”","D");
map.put("( )是Java中作为解析XML文档后生成的文档树模型\n" +
"\n" +
"A:Element类\n" +
"\n" +
"B: Document类\n" +
"\n" +
"C: Node类\n" +
"\n" +
"D: Text类","B");
map.put("Xml文档中的标签以下说法不正确的是( )\n" +
"\n" +
"A: 标签必须关闭\n" +
"\n" +
"B: 标签的属性值必须用引号引起来\n" +
"\n" +
"C: xml标签不区分大小写\n" +
"\n" +
"D: 一个格式良好的xml必须有根元素","C");
map.put("根据下列xml文档实例,选择说法不正确的是( )\n" +
"\n" +
"```xml\n" +
"\n" +
"\n" +
" \n" +
" Harry Potter \n" +
" J K. Rowling \n" +
" 2005 \n" +
" 29.99 \n" +
" \n" +
"\n" +
"```\n" +
"\n" +
"A: 和 是属性节点\n" +
"\n" +
"B: 和 是元素节点\n" +
"\n" +
"C:category是一个属性节点\n" +
"\n" +
"D:、、 和 是元素节点" ,"A");
map.put("根据下列DTD约束,选择书写不正确的xml实例文档( )\n" +
"\n" +
"```xml-dtd\n" +
"\n" +
"\n" +
"\n" +
"\n" +
" \n" +
"```\n" +
"\n" +
"\n" +
"\n" +
"```xml\n" +
"A:\n" +
" \n" +
"\t \n" +
" \n" +
" James \n" +
" \n" +
" \n" +
" James \n" +
" \t\n" +
"\t\n" +
"B:\n" +
" \n" +
"\t \n" +
" \n" +
" James \n" +
" \n" +
"\t\n" +
"C:\n" +
" \n" +
"\t \n" +
" \n" +
" James \n" +
" \n" +
" \n" +
" James \n" +
" \n" +
" \n" +
"D:\n" +
" \n" +
" \n" +
" \n" +
" James \n" +
" \n" +
" \n" +
"```\n" +
"\n","C");
map.put("根据下列需求,选择合适的选项完善代码( )\n" +
"\n" +
"需求:根据下图,解析book.xml获取id=01的书名,作者,价格打印输出到控制台\n" +
"\n" +
"```xml\n" +
"book.xml\n" +
"\n" +
"\n" +
" \n" +
" Java变成思想 \n" +
" James \n" +
" 79.00 \n" +
" 库存:30\n" +
" \n" +
"\n" +
"```\n" +
"\n" +
"```java\n" +
"public class Test01 {\n" +
" public static void main(String[] args) throws Exception{\n" +
" fun();\n" +
" }\n" +
"\n" +
" public static void fun() throws Exception{\n" +
" SAXReader saxReader = new SAXReader();\n" +
" Document document = saxReader.read(\"book.xml\");\n" +
" Element root = document.getRootElement();\n" +
" List bookList = root.elements(\"book\");\n" +
" Element bookElement = bookList.get(0);\n" +
" Element nameElement = bookElement.element(\"name\");\n" +
" Element authorElement = bookElement.element(\"author\");\n" +
" Element priceElement = bookElement.element(\"price\");\n" +
" System.out.println(\"书名:\"+ +\" 作者:\"+ authorElement.getText()+\" 价格:\"+ priceElement.getText());\n" +
" }\n" +
"}\n" +
"```\n" +
"\n" +
"A. document.getElements()\n" +
"B. document.getRootElement()\n" +
"C. nameElement.getText()\n" +
"D. nameElement.getelementText()","C");
int num = 0;
for (Map.Entry<String, String> stringStringEntry : map.entrySet()) {
num++;
}
System.out.println("----------------本系统一共有" + num + "道题----------------");
Judge(map,num - 1,num);
System.out.println("总得分:" + score);
}
public static int Judge(HashMap<String,String> map,int num,int number){
HashMap<String,String> map1 = new HashMap<>();
start = System.currentTimeMillis();
ArrayList<String> list = new ArrayList<>();
for (String s : map.keySet()) {
list.add(s);
}
Collections.shuffle(list);
for (String s : list) {
System.out.println(s);
String s1 = map.get(s);
System.out.print("请输入你的选择(输入'exit'退出):");
String response = sc.next();
if("exit".equals(response)){
num = num + 1;
break;
}
if(response.equalsIgnoreCase(s1)){
score += 1;
System.out.println("回答正确");
}else{
map1.put(s,s1);
score = score;
System.out.println("正确答案:" + s1);
}
System.out.println("-------------------还有" + num-- + "道题-------------------");
System.out.println("--------------------请看下一题--------------------");
}
end = System.currentTimeMillis();
System.out.println();
System.out.println();
System.out.println("输出错题:");
for (Map.Entry<String, String> stringStringEntry : map1.entrySet()) {
String key = stringStringEntry.getKey();
String value = stringStringEntry.getValue();
System.out.println(key + "\r\n答案:" + value);
}
System.out.println("一共有:" + number + "道题");
System.out.println("你做了:" + (number - num));
System.out.println("还 有:" + num + "道题没有做");
System.out.println("你对了:" + score);
System.out.println("你用时:" + ((end - start) / 1000) + "秒");
return score;
}
}