OCP Oracle Certified Professional Java SE 11 Developer Practice Tests. Jeanne Boyarsky
9, 10][1, 10, 9][9, 1, 10][9, 10, 1][10, 1, 9][10, 9, 1]
77 Which is the first line to prevent this code from compiling and running without error?char[][] ticTacToe = new char[3][3]; // r1 ticTacToe[0][0] = 'X'; // r2 ticTacToe[1][1] = 'X'; ticTacToe[2][2] = 'X'; System.out.println(ticTacToe.length + " in a row!"); // r3Line r1Line r2Line r3None of the above
78 What is true of the following code? (Choose three.)36: var names = new HashMap<String, String>(); 37: names.put("peter", "pan"); 38: names.put("wendy", "darling"); 39: 40: String w = names.getOrDefault("peter"); 41: String x = names.getOrDefault("peter", "x"); 42: String y = names.getOrDefault("john", "x");One line does not compile.Two lines do not compile.If any lines that do not compile are removed, the String on line 40 is set to null.If any lines that do not compile are removed, the String on line 41 is set to "pan".If any lines that do not compile are removed, the String on line 41 is set to "x".If any lines that do not compile are removed, the String on line 42 is set to "x".
79 What does the following output?18: List<String> list = List.of( 19: "Mary", "had", "a", "little", "lamb"); 20: Set<String> set = new HashSet<>(list); 21: set.addAll(list); 22: for(String sheep : set) 23: if (sheep.length()> 1) 24: set.remove(sheep); 25: System.out.println(set);[a, lamb, had, Mary, little][a][a, a]The code does not compile.The code throws an exception at runtime.
80 Which of the following fills in the blank so this code compiles?public static void getExceptions(Collection<__________> coll) { coll.add(new RuntimeException()); coll.add(new Exception()); }?? extends Exception? super ExceptionNone of the above
Конец ознакомительного фрагмента.
Текст предоставлен ООО «ЛитРес».
Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.
Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.