- •Import java.Util.*;
- •II and III only
- •I and II only
- •24) Consider the following uml class diagram.
- •25) Consider the following uml class diagram.
- •II only
- •30) Consider the following class definitions.
- •III only
- •I and II only
- •II only
- •I and III only
- •II and III only
- •I and II only
- •I and III only
- •II only
- •I and III only
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
0..*
1..*
I, II, and III
26) In object-oriented design, types of multiplicity for associations among classes include which of the following?
One-to-one
One-to-many
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?
Publication publication = new Book(2); int edition = publication.getEdition();
Publication publication = new Book(2); int edition = ((Book) publication).getEdition();
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?
public Book(String author) { this.author = author; }
public Book(String author, int edition) { this.edition = edition; super(author); }
public Book(int edition) { super(); this.edition = edition; }
III only
31) Which of the following statements about Java is (are) true?
One class can define two methods with the same signature.
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?
The signature of a constructor can include a return type.
The name of a constructor for a class can differ from the name of the class.
A constructor can be invoked using the dot notation.
None
33) Which of the following statements about static attributes in Java is (are) true?
Static attributes can be accessed by non-static methods in the same class.
A static attribute can be accessed even if no instance of the class in which the attribute is defined exists.
Static attributes can only be accessed by static methods.
