Chapter 12 AP Computer Science maybe

¡Supera tus tareas y exámenes ahora con Quizwiz!

35) A Quiz class contains an array of Question objects. This is best described as an example of ____. a) Aggregation b) Cohesiveness c) Association d) Inheritance

a

22) The dependency relationship is sometimes referred to as the ____ relationship. a) is-a b) has-a c) depends-on d) knows-about

d

8) A/an ____ represents a set of objects with the same behavior. a) Association b) Aggregation c) Dependency d) Class

d

18) Dependency between classes denotes that ____. a) Objects of one class inherit from objects of its superclass. b) Objects of one class can be inherited by its subclasses. c) Objects of one class implement an interface. d) Methods in the objects of one class use an object of another class.

d

21) UML means____. a) Unified Mode Language b) User Modeling Language c) User Mode Language. d) Unified Modeling Language.

d

38) Which statement correctly describes the class relationship shown in this diagram? QUIZ <>-------- QUESTION a) Quiz class depends on Question class b) Question class aggregates Quiz class c) Quiz class aggregates Question class. d) Question class inherits from Quiz class.

c

76) Select a code segment to complete the SmartPhone class, so that it reflects an interface implementation relationship between SmartPhone and MP3Player. public class SmartPhone ___________________________ a) extends MP3Player { ... } b) { private MP3Player musicPlayer; ... } c) implements MP3Player { ... } d) implements interface MP3Player { ... }

c

92) During the implementation phase, which of the following statements is true? a) Aggregated classes will yield subclasses. b) Aggregated classes will yield instance variables. c) Aggregated classes will yield class packages. d) Aggregated classes will yield interfaces.

b

95) When using UML to create state diagrams, a state is denoted by ____. a) A rectangle with double border. b) A rectangle with rounded corners. c) An oval with double border. d) A standard rectangle with square corners.

b

103) Suppose you are developing a payroll application that computes and displays weekly paycheck amounts for various employees. As a result of the design phase, an Employee class is developed. In addition, the Payroll class is designed to store and process information for various employees. Select the code segment that best completes the Payroll class. public class Payroll ___________________________ a) extends Employee { ... } b) { public static void main(String[] args) { Employee anEmployee; ... } c) { public static void main(String[] args) { int hoursWorked; double hourlyRate; ... } } d) { public static void main(String[] args) { ArrayList<Employee> employees; ... } }

d

15) A class (ClassOne) is considered to have a dependency on another class (ClassTwo) under which of the following conditions? a) Each class uses objects of the other. b) The public interfaces of both classes are cohesive. c) ClassTwo uses objects of ClassOne. d) ClassOne uses objects of ClassTwo.

d

6) You are designing an application to support a veterinary clinic. Which of the following probably should NOT be represented as an object? a) Pet b) Customer c) Medical service performed d) Drug dosage

d

71) Parallel arrays are ____. a) Two or more arrays or array lists of the same length which each store a part of what could be considered an object. b) Two or more arrays or array lists of the same length. c) Two or more arrays or array lists of the same data type. d) Two or more arrays or array lists that are declared one after the other in a program.

a

53) When designing classes, if you find classes with common behavior you should ____. a) Combine them all into a single class. b) Place the common behavior into a superclass. c) Place the common behavior into a subclass. d) Give them similar names.

b

55) In a UML diagram, the relationship symbol shown below denotes ____. <>---------- a) inheritance b) aggregation c) dependency d) interface implementation

b

59) Which statement correctly describes the class relationship shown in this diagram? VEHICLE <>----------- CAR a) Tire class aggregates Car class. b) Car class aggregates Tire class. c) Car class inherits from Tire class. d) Tire class inherits from Car class.

b

63) When using CRC cards, UML diagrams should be created ___. a) Prior to discovering classes. b) After you have discovered classes and their relationships. c) During the implementation phase. d) To produce final documentation of the system.

b

45) Consider the following code snippet: public class PowerBoat extends Vessel { private Engine[] engines; . . . } This code is best described as an example of ____. a) Inheritance and multiplicities. b) Aggregation and association. c) Inheritance and aggregation. d) Inheritance and dependency.

c

102) Suppose you are developing a payroll application that computes and displays weekly paycheck amounts for various employees. As a result of the design phase, the partial Employee class below is developed. Select the method header that best completes the class, according to the method comments. public class Employee { private int hoursWorked; /** Computes the weekly salary for this employee. @param hourlyRate the rate per hour earned by the employee @return the weekly salary */ _________________________________________ { // method body } } a) public void computeSalary(double hourlyRate) b) public double computeSalary(double hourlyRate, int hoursWorked) c) public double computeSalary(double hourlyRate) d) public double computeSalary(int hoursWorked)

c

11) When using the CRC method, other classes that are needed to fulfill the responsibilities of a given class are called its ____. a) Related classes. b) Responsible classes. c) Collaborators. d) Concurrent classes.

c

100) Regarding the invoice-printing application from section 12.3, it is decided that a Customer class is needed to store customer information, including the name, billing address, and a customer id number to be printed at the top of each invoice. Since the existing Address class already stores the customer's name and physical address, the new Customer class can simply reuse Address. Select the code segment that best illustrates how the Customer class can reuse the existing Address class. public class Customer ___________________________ a) extends Address { private String idNumber; ... } b) { private Address information; private String idNumber; ... } c) implements Address { private String idNumber; ... } d) { private Address information; private String name; private String street; private String city; private String state; private String zip; private String idNumber; ... }

b

27) ____ is often described as the has-a relationship. a) Inheritance. b) Aggregation. c) Polymorphism. d) Dependency.

b

29) Consider the following code snippet: public class Motorcycle { private Tire[] tires; . . . } This code is best described as an example of ____. a) Inheritance. b) Aggregation. c) Polymorphism. d) Association.

b

3) Which of the following would be an appropriate name for a game-related class? a) FinalizeLevelOne b) InitialLevel c) ResetTheCurrentLevel d) AscendToFinalLevel

b

31) Consider the following code snippet: public class Purse { private Coin[] coins; . . . } This code is best described as an example of ____. a) Inheritance. b) Aggregation. c) Polymorphism. d) Association.

b

37) In general, you need ____ when an object needs to remember another object between method calls. a) inheritance b) aggregation c) association d) an interface implementation

b

43) Consider the following code snippet: public class Motorcycle extends Vehicle { . . . } Which of the following statements correctly describes the relationship between the Motorcycle and Vehicle classes? a) Motorcycle exhibits the has-a relationship with regards to Vehicle. b) Motorcycle exhibits the is-a relationship with regard to Vehicle. c) Vehicle exhibits the has-a relationship with regards to Motorcycle. d) Vehicle exhibits the is-a relationship with regards to Motorcycle.

b

46) Consider the following code snippet: public class SailBoat extends Vessel { private Engine[] engines; private Sail mainsail; . . . } Which of the following statements is NOT correct? a) SailBoat inherits from Vessel. b) Sail depends on Sailboat. c) Sailboat aggregates Engine. d) SailBoat aggregates Sail.

b

48) Consider the following code snippet: public class Manager extends Employee { private Project[] projects; private Address address; . . . } Which of the following statements is NOT correct? a) Manager inherits from Employee. b) Address aggregates Manager. c) Manager aggregates Address. d) Manager aggregates Project.

b

49) In a UML diagram, inheritance is denoted by ____. a) A solid line with a diamond-shaped symbol next to the superclass. b) A solid line with a closed arrow tip pointing to the superclass. c) A dotted line with an open arrow tip pointing to the superclass. d) A solid line with an open arrow tip pointing to the superclass.

b

52) Which of the following code snippets denotes that the Rose class inherits from the Flower class? a) public class Flower extends Rose b) public class Rose extends Flower c) public class Rose { private Flower[] flowers; } d) public class Flower { private Rose[] limes; }

b

60) You have determined a need for a Book class and a Page class in your program. Which relationship is most appropriate between these classes? a) Inheritance b) Aggregation c) Dependency d) Interface implementation

b

64) Which of the following statements about class attributes is true? a) An attribute always corresponds to an instance variable of the class. b) An attribute is an externally observable property that objects of the class have. c) An attribute is used to represent aggregation with another class. d) Attributes cannot be represented in UML diagrams.

b

65) How does a UML diagram denote classes and their attributes and methods? a) A class rectangle contains the class name in the top, methods in the middle, and attributes in the bottom. b) A class rectangle contains the class name in the top, attributes in the middle, and methods in the bottom. c) A class rectangle contains the methods in the top, class name in the middle, and attributes in the bottom. d) A class rectangle contains the attributes in the top, methods in the middle, and class name in the bottom.

b

7) Classes often correspond to ____ in a requirements description. a) Verbs b) Nouns c) Dependencies d) Relationships

b

73) Select a code segment to complete the Name class, so that it reflects a dependency relationship between Name and String. public class Name ___________________________ a) extends String { ... } b) { private String first; private String second; ... } c) implements String { ... } d) { private ArrayList<String> names; ... }

b

78) Before you begin designing a solution, you should ____. a) Document the methods that will be needed. b) Gather and document all requirements for the program in plain English. c) Determine the classes that will be needed. d) Create the UML diagrams to represent the classes.

b

79) You are designing a software solution for an automobile rental company. You have decided that the following nouns apply to the requirements: Auto, Customer, Address, Rental Contract, Mileage, Rental Date, Daily Rate, Total. Which of these should be represented as classes? a) All of them. b) Auto, Customer, Address, Rental Contract. c) Auto, Customer, Address, Rental Contract, Mileage. d) Auto, Customer, Address, Rental Contract, Mileage, Rental Date, Daily Rate.

b

81) You are designing a software solution for a veterinary clinic. The clinic provides various services for each pet on each visit. You have decided that the following nouns apply to the requirements: Customer, Address, Pet, Visit, Visit Date, Service Charge, Total Charge, Next Appointment. Which of these should be represented as classes? a) All of them. b) Customer, Address, Pet, Visit. c) Customer, Address, Pet, Visit, Service Charge. d) Customer, Address, Pet, Visit, Service Charge, Total Charge, Visit Date, Next Appointment.

b

88) Given the following diagram showing class relationships: What type of relationship is shown between Invoice and Address? v- - - - - - - - - -INVOICE <>--------ADDRESS PRODUCT ^ | V |--------------<>LINEITEM a) Address inherits from Invoice. b) Invoice aggregates Address. c) Address aggregates Invoice. d) Invoice inherits from Address

b

93) During the implementation phase, which of the following statements is true? a) Method parameter variables are available from the CRC cards. b) Method parameter variables are available from the javadocs created during the design phase. c) You must determine the method parameter variables during implementation phase. d) Method parameter variables are available from the UML diagrams.

b

97) Given the following diagram showing class relationships: What of the following best describes the type of relationship shown between Bank and Customer? 1 [ATM] <>------------[BANK] ^ ^ V 1 V | -----------------[CUSTOMER] | ^ | 1 2 V |--[BANKACCOUNT]--| a) Customer aggregates Bank, indicating that a customer may deal with many banks. b) Bank aggregates Customer, indicating that a bank may deal with many customers. c) Bank depends on Customer, indicating that a bank may deal with many customers. d) Customer depends on Bank, indicating that a customer may deal with many banks.

b

12) When using the CRC method, if you determine that a class cannot carry out a particular task by itself and needs the help of another class to complete the task, you should ____. a) Do nothing on this class's CRC card. The task will be shown on the other class's CRC card. b) Add this class onto the other class's CRC card as a collaborator. c) Add the other class onto this class's CRC card as a collaborator. d) Add each class onto the other class's CRC card as a collaborator.

c

14) Under which of the following conditions would the public interface of a class be considered cohesive? a) All of its features are public and none of its features are static. b) The quality of the public interface is rated as moderate to high. c) All of its features are related to the concept that the class represents. d) It is obvious that the public interface refers to multiple concepts.

c

16) A UML class diagram would be most useful in visually illustrating which of the following? a) the cohesiveness of a class's interface. b) the amount of complexity of a class's interface. c) dependencies between classes. d) relationships between classes and their interfaces.

c

17) Why is it generally considered good practice to minimize coupling between classes? a) Low coupling increases the operational efficiency of a program. b) High coupling implies less interface cohesion. c) High coupling increases program maintenance and hinders code reuse. d) Low coupling decreases the probability of code redundancy.

c

19) In a UML diagram, dependency is denoted by ____. a) A dotted/dashed line with a closed arrow tip. b) A solid line with a closed arrow tip. c) A dotted/dashed line with an open arrow tip. d) A solid line with an open arrow tip.

c

2) Which of the following questions should you ask yourself in order to determine if you have named your class properly? a) Does the class name contain 8 or fewer characters? b) Is the class name a verb? c) Can I visualize an object of the class? d) Does the class name describe the tasks that this class will accomplish?

c

20) If many classes of a program depend on each other, we say that ____. a) cohesiveness is high. b) cohesiveness is low. c) coupling is high. d) coupling is low.

c

25) Which of the following code snippets denotes that the Pen class depends on the Ink class? a) public class Pen extends Ink b) public class Ink extends Pen c) public class Pen { private Ink anInk; } d) public class Ink { private Pen aPen; }

c

26) Which of the following code snippets denotes that the Kitchen class depends on the Stove class? a) public class Kitchen extends Stove b) public class Stove { private Kitchen[] kitchens; } c) public class Kitchen { private Stove aStove; } d) public class Kitchen implements Stove

c

39) Which of the following code snippets denotes that the Fleet class aggregates the Taxi class? a) public class Fleet extends Taxi b) public class Taxi extends Fleet c) public class Fleet { private ArrayList<Taxi> taxicabs; } d) public class Taxi { private Fleet myFleet; }

c

40) Which of the following code snippets denotes that the Kitchen class aggregates the Dish class? a) public class Kitchen extends Dish b) public class Dish extends Kitchen c) public class Kitchen { private Dish[] dishes; } d) public class Dish { private Kitchen myKitchen; }

c

42) Consider the following code snippet: public class Motorcycle extends Vehicle { private Tire[] tires; . . . } This code is best described as an example of ____. a) Inheritance and multiplicities. b) Aggregation and dependency. c) Inheritance and aggregation. d) Inheritance and association.

c

44) Consider the following code snippet: public class Motorcycle extends Vehicle { private Tire[] tires; private Engine anEngine; . . . } Which of the following statements describing relationships between the Motorcycle, Tire, Engine and Vehicle classes is NOT correct? a) Motorcycle exhibits the has-a relationship with regards to Tire. b) Motorcycle exhibits the is-a relationship with regard to Vehicle. c) Vehicle exhibits the has-a relationship with regards to Motorcycle. d) Motorcycle exhibits the knows-about relationship with regards to Engine.

c

5) You are designing an application to support an automobile rental agency. Which of the following probably should NOT be represented as an object? a) Auto b) Customer c) Payment amount d) Rental contract

c

62) ____ relationships come from the collaboration columns on the CRC cards. a) Association b) Inheritance c) Dependency d) Attribute

c

69) You have determined the need for a File class and a Folder class in your program. Which of the following would best describe the relationship between these classes? a) Aggregation b) Association c) Composition d) Inheritance

c

70) If you have parallel arrays or array lists of the same length which each store a part of what could be considered an object, ____. a) You should rewrite the program to use a two-dimensional array. b) You should rewrite the program to use a two-dimensional array list. c) You should create a class to hold the related data in the ith slice of each array, and then create an arraylist of objects. d) There are no alternatives to this type of program design.

c

72) To improve the quality of the public interface of a class, ____. a) You should maximize cohesion and minimize inheritance. b) You should minimize cohesion and maximize coupling. c) You should maximize cohesion and minimize coupling. d) You should minimize cohesion and maximize aggregation.

c

80) You are designing a software solution for an automobile rental company. You have decided that the following nouns apply to the requirements: Auto, Customer, Address, Rental Contract, Mileage, Rental Date, Daily Rate, Total. Which of these should be represented as instance variables? a) Mileage b) Mileage, Daily Rate. c) Mileage, Rental Date, Daily Rate. d) Mileage, Rental Date, Daily Rate, Total.

c

82) You are designing a software solution for a veterinary clinic. The clinic provides various services for each pet on each visit. You have decided that the following nouns apply to the requirements: Customer, Address, Pet, Visit, Visit Date, Service Charge, Total Charge, Next Appointment. Which of these should be represented as instance variables? a) Service Charge b) Service Charge, Visit Date. c) Service Charge, Visit Date, Next Appointment. d) Service Charge, Visit Date, Next Appointment, Total Charge.

c

67) Given the following diagram: What does this diagram indicate about the relationship between the customers and bank accounts? 1..* CUSTOMER <>------------------ BANKACCOUNT a) A bank account may be owned by only one customer. b) A bank account may be owned by one or more customers. c) A customer may have only one bank account. d) A customer may have one or more bank accounts.

d

68) Which of the following statements about associations between classes is true? a) A class is associated with another class if both classes are in the same package. b) A class is associated with another class if the class inherits from the other class. c) A class is associated with another class if the other class inherits from this class. d) A class is associated with another class if you can navigate from objects of one class to objects of the other class.

d

74) Select a code segment to complete the Team class, so that it reflects an aggregation relationship between Team and Player. public class Team ___________________________ a) extends Player { ... } b) { private Player aPlayer; ... Maha Otaibi 50 } c) implements Player { ... } d) { private ArrayList<Player> players; ... }

d

77) The textbook recommends a five-part program development process consisting of the following activities: I Use UML diagrams to record class relationships. II Gather requirements. III Implement the program. IV Use CRC cards to identify classes. V Use javadoc to document method behavior. Maha Otaibi 51 Which is the correct order in which these activities should be completed? a) IV, II, I, III, V b) IV, II, I, V, III c) II, IV, I, III, V d) II, IV, I, V, III

d

86) Given the following diagram showing class relationships: What type of relationship is shown between Invoice and Product? v- - - - - - - - - -INVOICE <>--------ADDRESS PRODUCT ^ | V |--------------<>LINEITEM a) Product inherits from Invoice. b) Product aggregates Invoice. c) Invoice inherits from Product. d) Invoice is dependent on Product.

d

94) During the implementation phase, which of the following statements is true? a) Class instance variables are available from the CRC cards. b) Class instance variables are available from the javadocs created during the design phase. c) You must determine the class instance variables during implementation phase. d) Class instance variables can be determined from the UML diagrams.

d

41) ____ is often described as the is-a relationship. a) Inheritance. b) Aggregation. c) Polymorphism. d) Dependency.

a

66) How does a UML diagram denote a multiplicity of one or more in an aggregation relationship? a) * b) 1..* c) *..1 d) 1..n

b

51) Which of the following code snippets denotes that the Lime class inherits from the Citrus class? a) public class Lime extends Citrus b) public class Citrus extends Lime c) public class Lime { private ArrayList<Citrus> fruits; } d) public class Citrus { private ArrayList<Lime> limes; }

a

54) In a UML diagram, an interface implementation is denoted by ____. a) A dotted line with a closed arrow tip. b) A solid line with a closed arrow tip. c) A dotted line with an open arrow tip. d) A solid line with an open arrow tip.

a

57) In a UML diagram, the relationship symbol shown below denotes ____. --------------------> a) inheritance b) aggregation c) dependency d) interface implementation

a

10) A CRC card describes ____. a) A class, its responsibilities, and its collaborating classes. b) A class, its methods, and its constructors. c) A class, its relationships, and its collaborating classes. d) A class, its requirements, and its concurrent classes.

a

30) Consider the following code snippet: public class Motorcycle { private Tire[] tires; . . . } Which of the following statements correctly describes the relationship between the Motorcycle and Tire classes? a) Motorcycle exhibits the has-a relationship with regards to Tire. Maha Otaibi 43 b) Motorcycle exhibits the is-a relationship with regard to Tire. c) Tire exhibits the has-a relationship with regards to Motorcycle. d) Tire exhibits the is-a relationship with regards to Motorcycle.

a

32) Consider the following code snippet: public class Purse { private Coin[] coins; . . . } Which of the following statements is correct? a) Purse aggregates Coin. b) Coin depends on Purse. c) The Coin class must be declared as an inner class within Purse. d) Coin inherits from Purse.

a

4) Which of the following would be an appropriate name for a class used in an inventory application? a) Product b) InitializeInventoryLevel c) ResetCurrentInventoryLevel d) ReceiveNewProducts

a

13) Which of the following is the most important consideration when designing a class? a) Each class should represent an appropriate mathematical concept. b) Each class should represent a single concept or object from the problem domain. c) Each class should represent no more than three specific concepts. d) Each class should represent multiple concepts only if they are closely related.

b

1) Which of the following most likely indicates that you have chosen a good name for your class? a) The name consists of a single word. b) You can tell by the name what an object of the class is supposed to represent. c) You can easily determine by the name how many concepts the class represents. d) The name describes what task the class will perform.

b

23) Which statement correctly describes the class relationship shown in this diagram? CASHREGISTER - - - - - - > COIN a) CashRegister class depends on Coin class b) Coin class depends on CashRegister class c) CashRegister class aggregates Coin class. d) Coin class inherits from CashRegister class.

b

104) Suppose you are developing a payroll application that computes and displays weekly paycheck amounts for various employees. As a result of the design phase, the partial Employee class below is developed. Select the method header that best completes the class, according to the method comments. public class Employee { private double hourlyRate; private int hoursWorked; /** Modifies the hourly rate for this employee. @param newHourlyRate the rate per hour earned by the employee */ _________________________________________ { // method body Maha Otaibi 57 } } a) public void changeRate(double newHourlyRate) b) public void changeRate(double newHourlyRate, int hoursWorked) c) public double changeRate(double newHourlyRate) d) public double changeRate(double newHourlyRate, int hoursWorked)

a

36) In a UML diagram, aggregation is denoted by ____. a) A solid line with a diamond-shaped symbol next to the aggregating class. b) An arrow with an open triangle pointing to the aggregating class. c) A dotted line with a diamond-shaped symbol next to the aggregating class. d) A dotted line with an open arrow tip pointing to the aggregating class.

a

50) Which of the followings statements about class relationships is correct? a) Inheritance represents the is-a relationship, while aggregation represents the has-a relationship. b) Inheritance represents the has-a relationship, while dependency represents the uses relationship. c) Aggregation represents the is-a relationship, while inheritance represents the uses relationship. d) Aggregation represents the has-a relationship, while dependence represents the is-a relationship.

a

61) You have determined a need for an Employee class and a TemporaryEmployee class in your program. Which relationship is most appropriate between these classes? a) Inheritance b) Aggregation c) Dependency d) Interface implementation

a

75) Select a code segment to complete the Player class, so that it reflects an inheritance relationship between Player and Person. public class Player ___________________________ a) extends Person { ... } b) { private Person thePlayer; ... } c) implements Person { ... } d) { private ArrayList<Person> players; ... }

a

84) You are designing a software solution for a veterinary clinic. The clinic provides various services for each pet on each visit. You have decided that the following classes are needed: Customer, Address, Pet, and Visit. Which of these should be represented as aggregation? a) Customer class aggregates Address, Pet, and Visit classes. b) Visit class aggregates Address class. c) Pet class aggregates Address class. d) Pet class aggregates Customer class.

a

89) The final step of the design phase recommended by the textbook is to ____. a) Write the documentation of the discovered classes and methods b) Write the code for each class and all of its methods. c) Identify the classes and methods that will be required. d) Create the UML diagrams to represent the classes.

a

9) After you have identified a set of classes needed for a program, you should now ____. a) Define the behavior of each class. b) Look for nouns that describe the tasks. c) Begin writing the code for the classes. d) Establish the relationships between the classes.

a

90) When documenting discovered classes and methods during the design phase, you should ____. a) Create a Java source file for each class, write the method signatures, and use javadoc comments to describe the methods, but leave the method bodies blank. b) Create a Java source file for each class and write code to implement all of its methods, and use javadoc comments to document them. c) Create a Java source file for each class, use javadoc comments to document the methods that are to be added later, but do not write any code for the methods. d) Documentation of methods should not be done during the design phase.

a

91) Which of the following can be used to record the behavior of classes? a) Javadoc comments b) Nouns and verbs in the problem description c) Polymorphism d) UML notation

a

96) When using UML to create state diagrams, state change is denoted by ____. a) Arrows with labels that connect rectangles. b) Double arrows with labels that connect rectangles. c) An oval between two rectangles, connected with arrows. d) Dividing the state rectangle into several parts, one for each state change.

a

98) Given the following diagram showing class relationships: What type of relationship is shown between BankAccount and Customer? 1 [ATM] <>------------[BANK] ^ ^ V 1 V | -----------------[CUSTOMER] | ^ | 1 2 V |--[BANKACCOUNT]--| a) Customer aggregates BankAccount, indicating that a customer may have 2 bank accounts. b) BankAccount aggregates Customer, indicating that 2 customers may share a bank account. c) BankAccount depends on Customer, indicating that many customers may have 2 bank accounts. d) Customer depends on BankAccount, indicating that a customer may have 2 bank accounts.

a

99) Suppose that the invoice-printing application from section 12.3 needs to be enhanced by including the computation and printing of sales taxes as needed. Since some vendors charge no sales taxes, the original Invoice class needs to be preserved. Select the code segment that best illustrates reuse of the existing Invoice class. public class TaxableInvoice ___________________________ a) extends Invoice { ... } b) { private Invoice originalInvoice; ... } c) implements Invoice { ... } d) { private ArrayList<Invoice> invoices; ... }

a

83) You are designing a software solution for an automobile rental company. A customer may rent only a single auto at a given time. You have decided that the following classes are needed: Auto, Customer, Address, Rental Contract. Which of these should be represented as aggregation? a) Rental Contract class aggregates Address class b) Rental Contract class aggregates Customer and Address classes. c) Rental Contract class aggregates Customer, Address, and Auto classes. d) Rental Contract class does not aggregate any of the other classes.

c

85) Given the following diagram showing class relationships: What type of relationship is shown between Invoice and LineItem? v- - - - - - - - - -INVOICE <>--------ADDRESS PRODUCT ^ | V |--------------<>LINEITEM a) LineItem inherits from Invoice. b) LineItem aggregates Invoice. c) Invoice aggregates LineItem. d) Invoice inherits from LineItem.

c

87) Given the following diagram showing class relationships: What type of relationship is shown between LineItem and Product? v- - - - - - - - - -INVOICE <>--------ADDRESS PRODUCT ^ | V |--------------<>LINEITEM a) Product inherits from LineItem. b) Product aggregates LineItem. c) LineItem aggregates Product. d) LineItem inherits from Product.

c

101) Suppose that the invoice-printing application from section 12.3 needs to be enhanced by making it possible for class InvoicePrinter to store several invoices to be printed. Select the code segment that best illustrates reuse of the existing Invoice class for this purpose. public class InvoicePrinter ___________________________ a) extends Invoice { ... } b) { public static void main(String[] args) { Invoice invoice1; Invoice invoice2; ... } c) implements Invoice { ... } d) { public static void main(String[] args) { ArrayList<Invoice> invoices; ... } }

d

24) Which of the following code snippets denotes that the Purse class depends on the Wallet class? a) public class Purse extends Wallet b) public class Wallet extends Purse c) public class Wallet { private Purse aPurse; } d) public class Purse { private Wallet aWallet; }

d

28) Which of the following statements is correct? a) Dependency is a stronger form of aggregation. b) Aggregation indicates high cohesiveness. c) Aggregation indicates low coupling. d) Aggregation is a stronger form of dependency.

d

33) Aggregation denotes that ____. a) Objects of one class inherit from objects of its superclass. b) Objects of one class can be inherited by its subclasses. c) Objects of one class contain references to objects of its superclass. d) Objects of one class contain references to objects of another class.

d

34) A CashRegister class contains an array list of Coin objects. This is best described as an example of ____. a) Association b) Inheritance c) Cohesiveness d) Aggregation

d

47) Consider the following code snippet: public class SailBoat extends Vessel { . . . } public class Catamaran extends SailBoat { . . . } Which of the following statements is NOT correct? a) SailBoat inherits from Vessel. b) Catamaran inherits from Vessel. c) Catamaran inherits from Sailboat. d) Catamaran depends on SailBoat.

d

56) In a UML diagram, the relationship symbol shown below denotes ____. - - - - - - - - - - - - > a) inheritance b) aggregation c) dependency d) interface implementation

d

58) Which statement correctly describes the class relationship shown in this diagram? VEHICLE <---------- CAR a) Vehicle class depends on Car class b) Car class depends on Vehicle class c) Vehicle class inherits from Car class. d) Car class inherits from Vehicle class.

d


Conjuntos de estudio relacionados

Artificial Airways Practice Questions

View Set

UNIT 8.4 - Polar Bonds and Molecules

View Set

Morris Cell Bio Exam 3 Troy University

View Set

and then there were none test (questions)

View Set