Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Baza_po_SSD-3.docx
Скачиваний:
0
Добавлен:
01.07.2025
Размер:
13.88 Кб
Скачать

24) Consider the following uml class diagram.

Which of the following kinds of associations is not indicated by the class diagram?

Specialization/generalization

25) Consider the following uml class diagram.

Which of the following may be substituted for X in the above diagram to represent a multiplicity between A and B?

  1. 1

  2. 0..*

  3. 1..*

I, II, and III

26) In object-oriented design, types of multiplicity for associations among classes include which of the following?

  1. One-to-one

  2. One-to-many

  3. Many-to-many

I, II, and III

27) In a UML diagram, a specialization/generalization relationship is characterized by a line between two classes and a _____ next to the _____ class.

triangle, generalization

28) Consider the following UML diagrams.

Which of the diagrams represents a specialization/generalization relationship in which X is the specialization of Y?

B

29) Consider the following class definitions.

public class Publication { private String author; } public class Book extends Publication { private int edition; public Book(int edition) { this.edition = edition; } public int getEdition() { return edition; } }

Based on these class definitions, which of the following program segments will compile?

  1. Publication publication = new Book(2); int edition = publication.getEdition();

  2. Publication publication = new Book(2); int edition = ((Book) publication).getEdition();

  3. Book book = new Book(2); if (book.getEdition() instanceof int) { System.out.println(book.getEdition()); }

II only

30) Consider the following class definitions.

public class Publication { private String author; public Publication() { this.author = "anonymous"; } public Publication(String author) { this.author = author; } } public class Book extends Publication { private int edition; //Constructor(s) to be added here }

Which of the following constructors can be added to the definition of class Book without causing compilation to fail?

  1. public Book(String author) { this.author = author; }

  2. public Book(String author, int edition) { this.edition = edition; super(author); }

  3. public Book(int edition) { super(); this.edition = edition; }

III only

31) Which of the following statements about Java is (are) true?

  1. One class can define two methods with the same signature.

  2. If class B extends class A and overrides method m, then the argument names in the definition of method m in class B must be identical to those in class A.

None

32) Which of the following statements about Java constructors is (are) true?

  1. The signature of a constructor can include a return type.

  2. The name of a constructor for a class can differ from the name of the class.

  3. A constructor can be invoked using the dot notation.

None

33) Which of the following statements about static attributes in Java is (are) true?

  1. Static attributes can be accessed by non-static methods in the same class.

  2. A static attribute can be accessed even if no instance of the class in which the attribute is defined exists.

  3. Static attributes can only be accessed by static methods.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]