Test 11 1 class Hash Test private static

  • Slides: 11
Download presentation
Test 11

Test 11

Вопрос 1. class Hash. Test { private static Set<String> set = new Linked. Hash.

Вопрос 1. class Hash. Test { private static Set<String> set = new Linked. Hash. Set<String>(); public static void main(String[] args) { set. add("one"); set. add("two"); set. add("three"); set. add("/u 000 a"); set. add("/u 000 d"); set. add("/u 000 c"); set. add("1"); set. add("2"); set. add("3"); for (String string : set) { System. out. print(string + " "); } } } a) Ошибка времени выполнения b) /u 000 a /u 000 c /u 000 d 1 2 3 one three two c) one two three /u 000 a /u 000 d /u 000 c 1 2 3 d) 3 2 two 1 /u 000 a one three /u 000 c /u 000 d e) Ошибка компиляции f) Ничего из вышеперечисленного

Вопрос 2. public class Integer. Test{ public static void main(String[] argv){ Integer i 1

Вопрос 2. public class Integer. Test{ public static void main(String[] argv){ Integer i 1 = new Integer("1"); Integer i 2 = new Integer("2"); Integer i 3 = Integer. value. Of("3"); int i 4 = i 1 + i 2 + i 3; System. out. println(i 4); } } a) Ошибка компиляции: Integer class has no constructors which take a String argument b) Ошибка компиляции: Incorrect argument passed to the value. Of method c) Ошибка компиляции: Integer objects cannot work with + operator d) Программа выведет "6" без кавычек

Вопрос 3. Какие из этих кусков кода не вызовут ошибок компиляции? a) try {

Вопрос 3. Какие из этих кусков кода не вызовут ошибок компиляции? a) try { System. out. println("Inside try-block"); } catch(Exception e) { } catch(IOException e) { } b) try { System. out. print("Inside empty try"); } System. out. print("n"); catch(Exception e) {} c) try { System. out. println("Inside try-block"); } catch(IOException e) { } d) try {System. out. println("Inside try-block"); } catch(Exception e) {}

Вопрос 4. a) class Tree. Test { b) private static Set<String> set = new

Вопрос 4. a) class Tree. Test { b) private static Set<String> set = new Tree. Set<String>(); public static void main(String[] args) { c) set. add("one"); set. add("two"); d) set. add("three"); set. add("/u 000 a"); e) set. add("/u 000 d"); set. add("/u 000 c"); set. add("1"); set. add("2"); set. add("3"); for (String string : set) { System. out. print(string + " "); } } } Ошибка времени выполнения /u 000 a /u 000 c /u 000 d 1 2 3 one three two one two three /u 000 a /u 000 d /u 000 c 1 2 3 3 2 two 1 /u 000 a one three /u 000 c /u 000 d Ошибка компиляции

Вопрос 5. abstract class Abstract { abstract Abstract meth(); } class Owner { Abstract

Вопрос 5. abstract class Abstract { abstract Abstract meth(); } class Owner { Abstract meth() { class Inner extends Abstract { Abstract meth() { System. out. print("inner "); return new Inner(); } } return new Inner(); } } public class Quest 9 { public static void main(String a[]) { Owner ob = new Owner(); Abstract abs = ob. meth(); abs. meth(); } } a) inner; b) inner; c) inner; d) ошибка компиляции;

Вопрос 6. Thread t 1=new Thread(); t 1. set. Priority(7); Thread. Group tg=new Thread.

Вопрос 6. Thread t 1=new Thread(); t 1. set. Priority(7); Thread. Group tg=new Thread. Group("TG"); tg. set. Max. Priority(8); Thread t 2=new Thread(tg, "t 2"); System. out. print("приоритет t 1=“ + t 1. get. Priority()); System. out. print(", приоритет t 2=“ + t 2. get. Priority()); a) приоритет t 1 = 7, приоритет t 2 = 5; b) приоритет t 1 = 7, приоритет t 2 = 8; c) приоритет t 1 = 10, приоритет t 2 = 8;

Вопрос 7. class T 1 implements Runnable{ public void run(){ System. out. print("t 1");

Вопрос 7. class T 1 implements Runnable{ public void run(){ System. out. print("t 1"); } } class T 2 extends Thread{ public void run(){ System. out. print("t 2 "); } } public class Quest 3 { public static void main(String[] args) { T 1 t 1 = new T 1(); T 2 t 2 = new T 2(t 1); t 1. start(); t 2. start(); } } a) t 1 t 2; b) t 2 t 1; c) ошибка компиляции: метод start() не определен в классе T 1; d) ничего из перечисленного.

Вопрос 8. public class Main { public static void main(String[] args) { int i

Вопрос 8. public class Main { public static void main(String[] args) { int i = 0; int j = 1; System. out. println(i += (j < i) ? (2) : (3)); //1 } } a) 1 b) 2 c) 3 d) Ошибка компиляции в строке 1

Вопрос 9. interface Animal { void eat(); } // Сюда вставить код public class

Вопрос 9. interface Animal { void eat(); } // Сюда вставить код public class House. Cat implements Feline { public void eat() { } } a) interface Feline extends Animal { } b) interface Feline extends Animal { void eat(); } c) interface Feline extends Animal { void eat() { } }

Вопрос 10. Какие из следующих фрагментов кода являются правильным кодом Java? a) Integer int

Вопрос 10. Какие из следующих фрагментов кода являются правильным кодом Java? a) Integer int 2 = new Integer (15); int 2; b) String A = "Test 1"; A -= "23"; c) Integer int 1 = new Integer (41); int 1 -= 33; d) String A = "Test 2"; A += "55";