Java Stream流、多线程、函数式接口及String比较相关面试题
Java Stream流、多线程、函数式接口及String比较相关面试题
题目1 (单选):
下列关于Stream流中获取功能有哪些( ) 选项 : A. Collection接口中的默认方法stream()生成流 B. Map接口中的默认方法stream()生成流 C. Arrays中的静态方法stream()生成流 D. Stream类中的静态方法stream()生成流
答案:ABCD
题目2 (单选):
下列关于Stream流中中间功能有哪些( ) 选项 : A. filter()方法用于对流中的数据进行过滤 B. sorted()方法将流中元素进行排序 C. collector()方法收集流中的数据 D. limit()方法截取指定参数个数的数据
答案:ABD
题目3 (单选):
下列关于Stream流中终结功能有哪些( ) 选项 : A. forEach()方法对流中的元素遍历 B. count()方法返回此流中的元素数 C. skip()方法跳过指定参数个数的数据 D. collector()方法收集流中的数据
答案:ABD
题目4 (单选):
观察以下Stream流代码,最终输出的结果为( )
1 public class Test {
2 public static void main(String[] args) {
3 ArrayList
A. 1 B. 2 C. '张翠山', '张无忌' D. '张无忌'
答案:B
题目5 (单选):
对于以下多线程创建代码补全( ) 1 public class MyThread01 { 2 public static void main(String[] args) { 3 MyThread mt = new MyThread(); 4 // 开启线程 5 位置3 6 } 7 } 8 class MyThread 位置1 Thread { 9 @Override 10 public void 位置2() { 11 for (int i = 1; i <= 100; i++) { 12 System.out.println('i:' + i); 13 } 14 } 15 }
A. 位置1: extends 位置2: run 位置3: mt.start(); B. 位置1: extends 位置2: run 位置3: mt.run(); C. 位置1: implements 位置2: run 位置3: mt.start(); D. 位置1: implements 位置2: run 位置3: mt.start();
答案:A
题目6 (单选):
对于以下多线程创建代码补全( ) 1 public class MyThread02 { 2 public static void main(String[] args) { 3 MyRunnable mr = new MyRunnable(); 4 Thread thread= new Thread(位置3); 5 thread.start(); 6 } 7 } 8 9 class MyRunnable 位置1 Runnable { 10 @Override 11 public void 位置2() { 12 for (int i = 1; i <= 100; i++) { 13 System.out.println('i:' + i); 14 } 15 } 16 }
A. 位置1: extends 位置2: run 位置3:mr B. 位置1: extends 位置2: call 位置3:'线程名' C. 位置1: implements 位置2: run 位置3:mr D. 位置1: implements 位置2: run 位置3:'线程名'
答案:C
题目7 (单选):
关于函数式接口说法正确的是( ) A.函数式接口必须使用@functioninterface注解 B.函数式接口中只能定义一个方法 C.函数式接口中可以定义多个抽象方法 D.函数式接口中只能定义一个抽象方法
答案:D
题目8 (单选):
Stream接口中返回流中元素个数的是( ) A.count() B.size() C.getSize() D.getCount()
答案:A
题目9 (单选):
能作为Stream接口中的forEach方法的参数的是( ) A.a -> System.out.println(a) B.(a,b) -> a>b C.a -> a>0 D.a -> a!=null
答案:A
题目10 (单选):
String内部实现了什么接口进行比较( ) A.Comparable B.interface C.MyTest D.编译错误
答案:A
原文地址: https://www.cveoy.top/t/topic/oemr 著作权归作者所有。请勿转载和采集!