Вопросы для подготовки к экзамену номер 1Z0-808 — Java SE 8 Programmer I

1.1 Which statement is true about methods?
Select the one correct answer.
(a) A method is an implementation of an abstraction.
(b) A method is an attribute defining the property of a particular abstraction.
(c) A method is a category of objects.
(d) A method is an operation defining the behavior for a particular abstraction.
(e) A method is a blueprint for making operations.

Метод - это операция определяющая поведение для конкретной абстракции. Java имплементирует абстракции используя классы у которых есть свойства и поведение. Поведение определяется операциями абстракции.

1.2 Which statement is true about objects?
Select the one correct answer.
(a) An object is what classes are instantiated from.
(b) An object is an instance of a class.
(c) An object is a blueprint for creating concrete realization of abstractions.
(d) An object is a reference.
(e) An object is a variable.

Объект является экземпляром класса. Объекты создаются из классов, которые имплементируют абстракции. Созданные объекты - это конкретные реализации этих абстракций. Объект не является ни ссылкой, ни переменной.

1.3 Which is the first line of a constructor declaration in the following code?
public class Counter { // (1)
 int current, step;
 public Counter(int startValue, int stepValue) { // (2)
  setCurrent(startValue); // (3)
  setStep(stepValue);
 }
 public int getCurrent() { return current; } // (4)
 public void setCurrent(int value) { current = value; } // (5)
 public void setStep(int stepValue) { step = stepValue; } // (6)
}
Select the one correct answer.
(a) (1)
(b) (2)
(c) (3)
(d) (4)
(e) (5)
(f) (6)

Конструктор в Java объявляется как метод, но не возвращает никакого значения.

1.4 Given that Thing is a class, how many objects and how many references are
created by the following code?
Thing item, stuff;
item = new Thing();
Thing entity = new Thing();
Select the two correct answers.
(a) One object is created.
(b) Two objects are created.
(c) Three objects are created.
(d) One reference is created.
(e) Two references are created.
(f) Three references are created.

Объекты создаются использованием оператора new. Объявление ссылки создает переменную для хранения соответствующего ссылочного значения.

1.5 Which statement is true about instance members?
Select the one correct answer.
(a) An instance member is also called a static member.
(b) An instance member is always a field.
(c) An instance member is never a method.
(d) An instance member belongs to an instance, not to the class as a whole.
(e) An instance member always represents an operation.

Член экземпляра - это поле или метод экземпляра. Эти члены принадлежат экземпляру класса, а не самому классу. Члены не объявленные явно как static в объявлении класса являются членами экземпляра.

1.6 How do objects communicate in Java?
Select the one correct answer.
(a) They communicate by modifying each other’s fields.
(b) They communicate by modifying the static variables of each other’s classes.
(c) They communicate by calling each other’s instance methods.
(d) They communicate by calling static methods of each other’s classes.

Объект взаимодействует с другим объектом путем вызова методов экземпляра у другого объекта.

1.7 Given the following code, which statements are true?
class A {
 protected int value1;
}
class B extends A {
 int value2;
}
Select the two correct answers.
(a) Class A extends class B.
(b) Class B is the superclass of class A.
(c) Class A inherits from class B.
(d) Class B is a subclass of class A.
(e) Objects of class A have a field named value2.
(f) Objects of class B have a field named value1.

1.8 Given the following code, which statements express the most accurate association?
class Carriage { }
class TrainDriver { }
class Train {
 private Carriage[] carriages;
 private TrainDriver driver;
 Train(TrainDriver trainDriver, int noOfCarriages) {
  carriages = new Carriage[noOfCarriages];
  driver = trainDriver;
 }
 void insertCarriage(Carriage newCarriage) { /* … */ }
}
Select the three correct answers.
(a) A Train object has an array of Carriage objects.
(b) A Train object owns an array of Carriage objects.
(c) A Train object owns Carriage objects.
(d) A Train object has a TrainDriver object.
(e) A Train object owns a TrainDriver object.
(f) A TrainDriver object is part of a Train object.
(g) An array of Carriage objects is part of a Train object.
(h) Carriage objects are part of a Train object.

Объект Train может использовать объекты TrainDriver и Carriage совместно с другими объектами Train, когда они их не используют. Другими словами объекты TrainDriver и Carriage могут пережить объект Train. Это пример агрегации (ключевое слово has). Однако объект Train владеет массивом объектов используемым им для управления вагонами. Продолжительность жизни массива объектов ограничена продолжительностью жизни объекта Train. Это пример композиции (ключевое слово owns).

1.9 Which command from the JDK should be used to compile the following source
code contained in a file named SmallProg.java?
public class SmallProg {
 public static void main(String[] args) { 
  System.out.println("Good luck!");
 }
}
Select the one correct answer.
(a) java SmallProg
(b) javac SmallProg
(c) java SmallProg.java
(d) javac SmallProg.java
(e) java SmallProg main

1.10 Which command from the JDK should be used to execute the main() method of
a class named SmallProg?
Select the one correct answer.
(a) java SmallProg
(b) javac SmallProg
(c) java SmallProg.java
(d) java SmallProg.class
(e) java SmallProg.main()

1.11 Which statement is true about Java?
Select the one correct answer.
(a) A Java program can be executed by any JVM.
(b) Java bytecode cannot be translated to machine code.
(c) Only Java programs can be executed by a JVM.
(d) A Java program can create and destroy objects.
(e) None of the above

JVM должна быть совместима с той платформой на которой разрабатывалась Java-программа. JIT-функция в JVM транслирует байт-код в машинный код. Другие, языки например, Scala, также могут компилироваться в байт-код и исполняться на JVM. Java программа может только создавать объекты, а их уничтожением занимается автоматический сборщик мусора.

2.1 Which of the following is not a legal identifier?
Select the one correct answer.
(a) a2z
(b) ödipus
(c) 52pickup
(d) _class
(e) ca$h
(f) _8to5

Первый символ идентификатора не может быть цифрой. Символ подчеркивания используется наравне с буквами.

2.2 Which of the following are not legal literals in Java?
Select the four correct answers.
(a) 0Xbad
(b) 0B_101_101
(c) 09
(d) +_825
(e) 1_2e4f
(f) '\x'
(g) "what\'s your fancy?"

(b, d) - Символ подчеркивания должен быть между цифрами. 
(c) - Цифры 9 нет в восьмеричной системе счисления.
(f) - Нет такой escape-последовательности.

2.3 Which statement is true?
Select the one correct answer.
(a) new and delete are keywords in the Java language.
(b) try, catch, and thrown are keywords in the Java language.
(c) static, unsigned, and long are keywords in the Java language.
(d) exit, class, and while are keywords in the Java language.
(e) return, goto, and default are keywords in the Java language.
(f) for, while, and next are keywords in the Java language.

В Java идентификаторы delete, thrown, exit, unsigned, и next не являются ключевыми словами. В Java есть ключевое слово goto, но оно зарезервировано и сейчас не используется.

2.4 Which of the following is not a legal comment in Java?
Select the one correct answer.
(a) /* // */
(b) /* */ //
(c) // /* */
(d) /* /* */
(e) /* /* */ */
(f) // //

2.5 Which of the following do not denote a primitive data value in Java?
Select the two correct answers.
(a) "t"
(b) 'k'
(c) 50.5F
(d) "hello"
(e) false

Строковые литералы являются объектами класса String. В Java есть следующие примитивные типы данных: boolean, byte, short, char, int, long, float, и double.

2.6 Which of the following primitive data types are not integer types?
Select the three correct answers.
(a) boolean
(b) byte
(c) float
(d) short
(e) double

2.7 Which integral type in Java has the exact range from -2147483648 (i.e., -231) to 2147483647 (i.e., 231 - 1), inclusive?
Select the one correct answer.
(a) byte
(b) short
(c) int
(d) long
(e) char

Комментариев нет:

Отправить комментарий