First Test CSC226

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

53. Draw a figure representing our abstract view of the structures created by the following code sequence. LLStringNode node1 = new LLStringNode("alpha"); LLStringNode node2 = new LLStringNode("beta"); LLStringNode node3 = new LLStringNode("gamma"); node1.setLink(node3); node2.setLink(node3);

Answer: Look at these

15. We deal with ADTs on three levels. On which level do we just need to know how to use the ADT? A. application (or user, client) B. machine (or assembly) C. logical (or abstract) D. primitive (or language dependent) E. implementation (or concrete)

Answer: A

41. Testing a method by itself is called A. Unit testing B. Inspection C. Desk checking D. Black box testing E. Walkthrough

Answer: A

22. What does the acronym ADT stand for?

Answer: Abstract Data Type

18. A data type whose properties (domain and operations) are specified independently of any particular implementation is a(n) ___________________________ .

Answer: Abstract Data Type or ADT

50. Suppose we have a linked list of Strings, as defined in the textbook, named presidents. Suppose it contains three nodes, with the first node holding "Adams", the second node "Washington", and the third node "Kennedy". What would be output by the following code: LLStringNode temp = presidents; System.out.println(temp.getInfo());

Answer: Adams

24. Abstract methods do not have any code, so what can they be used for?

Answer: An abstract method is used to define the interface (or signature) of its corresponding concrete methods.

23. What are the three perspectives, or levels, with which we deal with ADTs?

Answer: Application (or user or client) level. Logical (or abstract) level. Implementation (or concrete) level.

17. We deal with ADTs on three levels. On which level do we just deal with the "what" questions, as in what does the ADT model, what are its responsibilities, what is its interface? A. application (or user, client) B. machine (or assembly) C. logical (or abstract) D. primitive (or language dependent) E. implementation (or concrete)

Answer: C

57. A StringLog is A. An array B. A linked list C. A container that holds strings D. An interface E. None of these

Answer: C

35. The repeated use a method name with a different signature is an example of A. an interface B. a subclass C. a transformer D. overloading E. none of these

Answer: D

16. We deal with ADTs on three levels. On which level do we deal with the "how" questions, as in how we represent the attributes and fulfill the responsibilities of the ADT? A. application (or user, client) B. machine (or assembly) C. logical (or abstract) D. primitive (or language dependent) E. implementation (or concrete)

Answer: E

42. A verification method in which the team performs a manual simulation of the program or design is called A. Unit testing B. Inspection C. Desk checking D. Black box testing E. Walkthrough

Answer: E

1. True or False? An abstraction of a system is a model of the system that includes all the details about the system.

Answer: False

10. True or False? A class that implements an interface can leave out methods that are required by the interface.

Answer: False

12. True or False? An interface definition can include concrete methods.

Answer: False

13. True or False? A Java interface must have at least one defined constructor.

Answer: False

14. True or False? You can instantiate objects of an interface.

Answer: False

3. True or False? UML diagrams are not a form of abstraction, since they hide details and only allow us to concentrate on the major design components.

Answer: False

4. True or False? When you code a method that has preconditions the first thing you should have the code do is check that the preconditions are true.

Answer: False

55. The LinkedStringLog implementation provided in Chapter Two is an example of a bounded implementation of a StringLog.

Answer: False

6. True or False? An abstract method must not have any comments.

Answer: False

7. True or False? In order to be used, an interface must implement a class.

Answer: False

8. True or False? A class can extend an interface.

Answer: False

64. What step in the design process usually follows brainstorming of the identification of classes?

Answer: Filtering the results of the brainstorming

48. What are the three general cases of insertion into a linked list that we must consider?

Answer: Insertion into the beginning of a list, insertion into the end of a list, and insertion into the middle of a list.

44. Explain the difference between software validation and verification.

Answer: Software validation - fulfills intended purpose Software verification - fulfills its specifications.

52. Suppose we have a linked list of Strings, as defined in the textbook, named presidents. Suppose it contains three nodes, with the first node holding "Adams", the second node "Washington", and the third node "Kennedy". What would be output by the following code: LLStringNode temp = presidents; while (temp != null) { temp = temp.getLink(); } System.out.println(temp.getInfo());

Answer: There will be an error message printed since we are attempting to access an object through a null reference.

11. True or False? An interface definition can include constant declarations.

Answer: True

2. True or False? UML diagrams are a form of abstraction, since they hide details and allow us to concentrate just on the major design components.

Answer: True

34. The ArrayStringLog implementation provided in Chapter Two is an example of a bounded implementation of a StringLog.

Answer: True

5. True or False? An abstract method must not have any executable code.

Answer: True

56. The LinkedStringLog implementation provided in Chapter Two is an example of an unbounded implementation of a StringLog.

Answer: True

9. True or False? A class that implements an interface can include methods that are not required by the interface.

Answer: True

51. Suppose we have a linked list of Strings, as defined in the textbook, named presidents. Suppose it contains three nodes, with the first node holding "Adams", the second node "Washington", and the third node "Kennedy". What would be output by the following code: LLStringNode temp = presidents; temp = temp.getLink(); System.out.println(temp.getInfo());

Answer: Washington

26. What are the benefits we accrue by using a Java interface construct to formally specify of ADTs?

Answer: We can check the syntax of our specification by compiling the interface. We can verify that the interface "contract" is satisfied by a class that implements the interface. We can provide a consistent interface to applications from among alternative implementations of the ADT.

33. What happens if you include the following code in an application that has access to the StringLogInterface? StirngLogInterface newLog = new StringLogInterface();

Answer: You get a syntax error since you cannot instantiate interfaces.

19. The Java ______________ mechanism can be used by Java programmer's to create their own ADTs.

Answer: class

25. What kinds of constructs can be declared in a Java interface?

Answer: constants (final variables) and abstract methods

21. The Java _________________ construct is used to formally specify the logical level of our ADTs.

Answer: interface

63. A standard technique for identifying classes and their attributes and responsibilities is to look for ideas in the problem statement. Candidate objects and their attributes are sometimes found in the __________ . And the __________ are often associated with responsibilities and actions.

Answer: nouns, verbs

46. In our linked list implementation what is the value of the link attribute of the last node on a list?

Answer: null

Assumptions that must be true upon entry into a method for it to work correctly are _________________________ .

Answer: preconditions

45. A(n) ____________________________ class includes an instance variable or variables that can hold a reference to an object of the same class.

Answer: self-referential

36. A method's name, the number and type of parameters that are passed to it, and the arrangement of the different parameter types within the parameter list combine to form what Java calls the ___________________ of the method.

Answer: signature

43. A(n) ____________________ is a program that calls operations exported from a class, allowing us to test the results of the operations.

Answer: test driver

47. Write pseudocode for traversing a linked list and displaying the information contained in its nodes.

Set currentNode to the first node on the list While (currentNode is not null) display the information at currentNode change currentNode to point to the next node on the list

49. Write code to insert the LLStringNode firstNode into the front of the myList linked list of nodes.

firstNode.setLink(myList); myList = firstNode;

40. Complete the implementation of the isFull method: public boolean isFull() // Returns true if this StringLog is full, otherwise returns false. { // complete the method body }

if (lastIndex == (log.length - 1)) return true; else return false;

39. Complete the implementation of the insert method: public void insert(String element) // Precondition: This StringLog is not full. // // Places element into this StringLog. { // complete the method body }

lastIndex++; log[lastIndex] = element;

//--------------------------------------------------------------------- // ArrayStringLog.java by Dale/Joyce/Weems Chapter 2 // // Implements StringLogInterface using an array to hold log strings. //--------------------------------------------------------------------- package ch02.stringLogs; public class ArrayStringLog implements StringLogInterface { protected String name; // name of this log protected String[] log; // array that holds log strings protected int lastIndex = -1; // index of last string in array 38. Complete the implementation of the following constructor: public ArrayStringLog(String name, int maxSize) // Precondition: maxSize > 0 // // Instantiates and returns a reference to an empty StringLog object // with name "name" and room for maxSize strings. { // complete the method body }

log = new String[maxSize]; this.name = name;

58. Complete the following table by entering the Big-O execution time of the indicated operations when using the LinkedStringLog class, assuming a list size of N. method efficiency constructor _______ insert _______ clear _______ clear and reclaim _______ isFull _______ getName _______ size _______ toString _______ contains _______

method efficiency constructor O(1) insert O(1) clear O(1) clear and reclaim O(N) isFull O(1) getName O(1) size O(N) toString O(N) contains O(N)

37. Complete the following table by entering the Big-O execution time of the indicated operations when using the ArrayStringLog class, assuming a list size of N. method efficiency constructor _______ insert _______ clear _______ clear and reclaim _______ isFull _______ getName _______ size _______ toString _______ contains _______

method efficiency constructor O(maxsize) insert O(1) clear O(N) isFull O(1) getName O(1) size O(1) toString O(N) contains O(N)


संबंधित स्टडी सेट्स

NUR334 PrepU: Chapter 24 - Structure and Function of the Kidney

View Set

Grade 7 - Chapter 5 - Expressions

View Set

Chapter 1 - Health and Accident Insurance

View Set

Chapter 1: Drug Use - An Overview

View Set

3.1, 3.2, & 3.3 MCQs to Check for Understanding

View Set