1z0-809 128q.pdf(ocp jdk8)-CSDN下载

所需积分/C币:50 2018-03-13 23:50:53 9.20MB PDF
收藏 收藏

oracle公司java8 Java SE 8 Programmer II 认证考试1z0-809题库 总128题
IntStream newStream stream map(in fu. apply aiNt (10) Answer: D Question: 3 Given the code fragment List<Integer> values Arrays asList(1, 2, 3); values. stream o map(n→>n*2 //line n1 peek(System. out: print) //line n2 counto What is the result? A.246 B The code produces no output C. A compilation error occurs at line n1 D. A compilation error occurs at line n2 Answer: A Question: 4 Given the code fragment public class Foo i public static void main(String [ args)I Map<Integer, String> unsortMap= new HashMap<>(; unsortMap. put(10, z; unsortMap put 5, b") unsortMap put(1,"d); unsortMap. put(7, "e); unsortMap. put(50, ) Map<Integer, String>treeMap new TreeMap <Integer, String>(new Comparator<Integer>(i @Overridepublicintcompare(Integerol,Integero2)freturno2.compareTo 01);}} treeMap. putAll(unsortMap; for(Map Entry<Integer, String> entry: treeMap. entrySet o)i System. out. print(entrygetvalue(+") What is the result? A. A compilation error occurs B d be zj Cjz e b d D.zbd Answer: c Question: 5 Which two reasons should you use interfaces instead of abstract classes? A You expect that classes that implement your interfaces have many common methods or fields, or require access modifiers other than public B You expect that unrelated classes would implement your interfaces. C. You want to share code among several closely related classes D. You want to declare non -static on non -final fields E You want to take advantage of multiple inheritance of type Answer:,e Explanation Refere http://www.programmerinterview.com/index.php/java-questions/interface-vs-abstract-class/ Question: 6 Given public class counter i public static void main(String[ args)i int a=10 nt b=-1: assert(b>=1): Invalid Denominator int c=a/b; System. out. println(c) What is the result of running the code with the -ea option? A.-10 C. An assertion Error is thrown D. A compilation error occurs Answer: b Question: 7 Given: class bird i public void fly oi system. out. print( Can fly); y class Penguin extends Bird i public void fly oi system. out. print( Cannot fly); and the code fragment class Birdie i public static void main (String args)i fly((->new Bird() fly(enguin: new); / line n1*/ Which code fragment when inserted at line n1, enables the birdie class to com pile? A static void fly(consumer< Bird> bird)i bird: fly (; B static void fly(Consumer<? extends bird> bird)i bird. accept() fly o; C static void fly Supplier< Bird> bird)t d get( fly o D static void fly (supplier<? extends bird> bird)t LOST Answer: C NOTE: Very confusing question. There is no logic in the options Question: 8 Given 1. abstract class Shape i 2345 Shapeoi system out printIn ("Shape") protected void area oi System. out println"Shape);y 6. class Square extends shape i int side Square int side i / insert code here * 10 this side side: 11 12. public void area(i System. out. println( "square);J 13 14. class rectangle extends square 15. int len br 16. Rectangle(int x, inti 17 / insert code here 18 len =X, br=y; 19 20. void area(i System. out. printIn ("Rectangle");I Which two modifications enable the code to compile? A. At line 1. remove abstract B At line 9, insert super (; C At line 12, remove public D. At line 17, insert super(x E. At line 17, insert super (; super side=X; F. At line 20, use public void area([ Answer: CD Question: 9 Given class Sum extends Recursive Action I //line n1 static final int THRESHold size =3: int stlndex, listindex int[ data; public Sum(int ]data, int start, int end)i his stIndex= start. this. Stundeⅹ=end protected void computed int sum=o if (lstlndex-stlndex <=THRESHOLD SIZE)I for(int i= stIndex; i< lstIndex i++)i sum + data [i] System. out. printIn(sum) F else i new Sum(data, stlndex THRESHOLD SIZE, Istlndex)fork() new Sum(data, stlndex, Math. min(lstIndex, stIndex +THRESHOLD SIZE) ) compute 0: and the code fragment Forkjoin Pool fjpool new ForkJoin Pool( int data[]={1,2,3,4,5,6,7,8,9,10} fPool invoke(new Sum(data, 0, data length)) and given that the sum of all integers from 1 to 10 is 55 Which statement is true? A. The program prints several values that total 55 B The program prints 55 C. a compilation error occurs at line n1 D. The program prints several values whose sum exceeds 55 Answer: c Question: 10 Given: public class Fook, V> I private K key private V value; public Foo (k key, v value)(this key =key; this value=value public static <T> Foo<T, T> twice(T value)(return new Foo<T, T>(value, value);) public k getKey o(return key public V getvalueo(return value; Which option fails? A Foo<String, Integer> mark= new Foo<String Integer>("Steve,100); B Foo<String, String> pair Foo <String>twice("Hello World! C Foo<?, ? percentage new Foo <>(97, 32) D Foo<String, String> grade new Foo <>John",A"; Answer: c Question: 11 Given the code fragment Stream<List<String>> iStr= Stream of Arrays. asList ("1",John") Arrays. aslist( 2", null)0 Stream<<String> nInSt =iStr flat MapTolnt((x)->Xstream o) nInSt forEach( System. out: print) What is the result? A. 1John2null B.12 C. A NullPointerException is thrown at run time D. A compilation error occurs Answer: C Question: 12 Given the code fragment Path file= Paths. get "courses. txt") // line n1 Assume the courses. txt is accessible Which code fragment can be inserted at line n1 to enable the code to print the content of the courses txt file? A. ListsString> fc= Files list(file); fc stream( forEach(s-> System. out. printIn(s)) B. Stream<String> fc= Files. readAll Lines(file) fc. for Each(s-> System. out. printIn(s) C. List<string> fc= readAllLines (file) fc stream(for Each(s-> System. out. printIn s)) D. Stream<String> fc= files. lines (file); fc. for Each(s-> System. out. printIn(s)); Answer: B Question: 13 Given the code fragment public void recDelete(String dir Name) throws IOException i File d listofFiles new File(dirName). listFileso if (listofFiles =null & listofFiles length >0)[ for(File a File: listOfFiles)i if (aFile is Directory o) Delete(aFile. getAbsolute Path () s else i if (aFilegetName(ends With("class") a File delete 0: Assume that projects contains subdirectories that contain. class files and is passed as an argument to the recdelete o method when it is invoked What is the result? A. The method deletes all the. class files in the projects directory and its subdirectories. B the method deletes the. class files of the projects directory only. C. The method executes and does not make any changes to the projects directory D. The method throws an loException Answer: B Question: 14 Given the code fragments 4. void dostuff( throws ArithmeticException, NumberFormatException, Exception i if(Math. random >-1 throw new Exception " Try again); 6.} and 24. try t 25 dostuff (: 26.] catch(ArithmeticException I NumberFormatException Exception e)i 27. System. out. println(e getMessage(); 1 28. catch(Exception e[ 29 System. out. printIn(e getMessage(); 1 Which modification enables the code to print try again? A. Comment the lines 28, 29 and 30 B Replace line 26 with y catch(Exception ArithmeticException Number FormatException e)t C Replace line 26 with 3 catch(ArithmeticException NumberFormatException e) D. Replace line 27 with throw e Answer: c Question: 15 Given the definition of the Country class public class country i public enum Continent ASIA, EUROPEy String name; Continent region; public Country( String na, Continent reg name = na, region = reg public String getName(return name public Continent getRegion ireturn region; 1 and the code fragment List< Country> couLis= Arrays. asList( new Country(Japan", Country. Continent ASIA) new Country italy, Country. Continent. EUROPE) new Country germany", Country Continent EUROPED) Map<Country. Continent, List<string>> region Names= coulist stream o collect(Collectors. grouping By (Country: getRegion, Collectors. mapping country: getName, Collectors tolist()); System. out. println(region Names What is the output? A. EUROPE=[Italy Germany, asia japan] B. ASIA= [Japan, EUROPE =[Italy, Germany ly C. EUROPE =[Germany, Italy, ASIA=[Japanll D. EUROPE =[Germany], EUROPE =[Italy], ASIA=[Japan1] Answer: A Question: 16 Given the code fragment Map<Integer, String> books new TreeMap<>o books. put(1007,“A"); books. put(1002,“C"); books. put(1001,“B"); books. put(1003,“B"); System. out. printIn(books) What is the result? A.{1007=A,1002=C,1001=B,1003=B B.{1001=B,1002=C1003=B,1007=A C.{1002=C1003=B,1007=A} D.{1007=A,1001=B,1003=B,1002=C} Answer: D Question: 17 Given: class book i String name public book(int id, String namei this name s name public boolean equals(object obj) / line n1 boolean output false: Book b=(Book)obj if (this name. equals(b name)) output true return output and the code fragment Book b1= new Book(101, Java Programing); Book b2= new Book(102, Java programing)i System. out. println(b1.equals(b2)) //line n2 Which statement is true? A. the program prints true B The program prints false C. A compilation error occurs. To ensure successful compilation, replace line n1 with boolean equals (Book obj) D. A compilation error occurs. To ensure successful compilation replace line n2 with: System. out. printIn(b1.equals(object) b2)) Answer: C Question: 18 Given the content of /resourses/Message properties welcome 1="Good day! and given the code fragment Properties prop= new Properties o FilelnputStream fis= new FilelnputStream("/resources/Message properties; prop. load(fis); System. out. printIn(prop. getProperty welcome");

试读 68P 1z0-809 128q.pdf(ocp jdk8)-CSDN下载
立即下载 低至0.43元/次 身份认证VIP会员低至7折
tanghin 里面带有答案的,作为笔试题做准备还是不错
广ོ红ོ 很實用的材料
qjxxjq12345 还没有看内容
关注 私信
1z0-809 128q.pdf(ocp jdk8)-CSDN下载 50积分/C币 立即下载
1z0-809 128q.pdf(ocp jdk8)-CSDN下载第1页
1z0-809 128q.pdf(ocp jdk8)-CSDN下载第2页
1z0-809 128q.pdf(ocp jdk8)-CSDN下载第3页
1z0-809 128q.pdf(ocp jdk8)-CSDN下载第4页
1z0-809 128q.pdf(ocp jdk8)-CSDN下载第5页
1z0-809 128q.pdf(ocp jdk8)-CSDN下载第6页
1z0-809 128q.pdf(ocp jdk8)-CSDN下载第7页
1z0-809 128q.pdf(ocp jdk8)-CSDN下载第8页
1z0-809 128q.pdf(ocp jdk8)-CSDN下载第9页
1z0-809 128q.pdf(ocp jdk8)-CSDN下载第10页
1z0-809 128q.pdf(ocp jdk8)-CSDN下载第11页
1z0-809 128q.pdf(ocp jdk8)-CSDN下载第12页
1z0-809 128q.pdf(ocp jdk8)-CSDN下载第13页
1z0-809 128q.pdf(ocp jdk8)-CSDN下载第14页

试读结束, 可继续读6页

50积分/C币 立即下载 >