Download Object-Oriented Programming Concepts and more Exams Data Acquisition in PDF only on Docsity!
MIS 505 Final Exam Review
Chapter 10: Object-Oriented Programming
TRUE/FALSE
- Methods in object-oriented programs use sequence, selection, and looping structures and make use of arrays.
ANS: T PTS: 1 REF: 408
- In addition to their attributes, class objects have methods associated with them; every object that is an instance of a class possesses different methods.
ANS: F PTS: 1 REF: 411
- Within any object-oriented program, you continuously make requests to objects’ methods, often including arguments as part of those requests.
ANS: T PTS: 1 REF: 411
- Declaring a class does not create actual objects.
ANS: T PTS: 1 REF: 415
- Class diagrams are a type of Unified Modeling Language (UML) diagram.
ANS: T PTS: 1 REF: 417
- The accessor method is another name for the set method.
ANS: F PTS: 1 REF: 421
- Object-oriented programmers usually specify that their data fields will have private access.
ANS: T PTS: 1 REF: 424
- All methods require a this reference.
ANS: F PTS: 1 REF: 432
- No object is necessary with a static method.
ANS: T PTS: 1 REF: 435
- Methods in a class are static instance methods by default.
ANS: F PTS: 1 REF: 435
MULTIPLE CHOICE
- ____ is a style of programming that focuses on an application’s data and the methods you need to manipulate that data. a. Classical programming c. Procedural programming b. Functional programming d. Object-oriented programming
ANS: D PTS: 1 REF: 408
- Object-oriented programmers sometimes say an object is one ____ of a class. a. enumeration c. member b. instantiation d. reference
ANS: B PTS: 1 REF: 408
- Objects both in the real world and in object-oriented programming contain ____ and methods. a. behaviors c. help b. attributes d. primitive data types
ANS: B PTS: 1 REF: 409
- ____ are the characteristics that define an object as part of a class. a. Instances c. Behaviors b. Attributes d. Methods
ANS: B PTS: 1 REF: 409
- When you think in an object-oriented manner, every object is a member of a ____. a. class c. method b. struct d. collection
ANS: A PTS: 1 REF: 410
- Object-oriented programmers also use the term ____ when describing inheritance. a. has-a c. is-a b. from-a d. contains
ANS: C PTS: 1 REF: 410
- The concept of a class is useful because of its ____. a. reusability c. abstract nature b. mapping to reality d. portability
ANS: A PTS: 1 REF: 410
- Object attributes are often called ____ to help distinguish them from other variables you might use. a. rows c. columns b. records d. fields
ANS: D PTS: 1 REF: 411
- The data components of a class that belong to every instantiated object are the class’s ____. a. numeric variables c. instance variables b. string variables d. data variables
ANS: C PTS: 1 REF: 411
a. get method c. pull method b. set method d. access method
ANS: A PTS: 1 REF: 421
- A ____ method is also known as a help method. a. work c. public b. private d. set
ANS: A PTS: 1 REF: 422
- A(n) ____ is the adjective defining the type of access (public or private) that outside classes will have to the attribute or method. a. control specifier c. access specifier b. control modifier d. access controller
ANS: C PTS: 1 REF: 424
- In a class method, the ____ reference can be used only with identifiers that are field names. a. my^ c. that b. this^ d. me
ANS: B PTS: 1 REF: 433
- ____ methods are those for which no object needs to exist. a. Dynamic c. Static b. Public d. Private
ANS: C PTS: 1 REF: 435
- ____ methods are methods that exist to be used with an object created from a class. a. Nonstatic c. Hidden b. Static d. Controlled
ANS: A PTS: 1 REF: 435
- In most programming languages, you use the word ____ when you want to declare a static class member. a. private c. public b. friend^ d. static
ANS: D PTS: 1 REF: 435
COMPLETION
- A(n) ____________________ is one instance of a class.
ANS: object
PTS: 1 REF: 408
- When you think in an object-oriented manner, everything is a(n) ____________________.
ANS: object
PTS: 1 REF: 410
- When you program in object-oriented languages, you frequently create ____________________ from which objects will be instantiated.
ANS: classes
PTS: 1 REF: 411
- With object-oriented programming, you focus on the ____________________ that will be manipulated by the program.
ANS: objects object
PTS: 1 REF: 408
- Any time a local variable in a method has the same identifier as a class field, the class field is ____________________.
ANS: hidden
PTS: 1 REF: 434
MATCHING
Match each term with a statement below. a. instance variables f. state b. class client g. polymorphism c. inheritance h. attributes d. class i. encapsulation e. information hiding j. object
- Describes a group or collection of objects with common attributes
- An instance of a class
- The characteristics that define an object as part of a class
- The data components of a class that belong to every instantiated object
- The set of all the values or contents of a class object’s instance variables
- A program or class that instantiates objects of another prewritten class
- Multiple methods with the same name, which will act differently and appropriately when used with different types
- The process of acquiring the traits of one’s predecessors
- The process of combining all of an object’s attributes and methods into a single package
- The concept that other classes should not alter an object’s attributes—only the methods of an object’s own class should have that privilege
- ANS: D PTS: 1 REF: 408
- ANS: J PTS: 1 REF: 408
- ANS: H PTS: 1 REF: 409
- ANS: A PTS: 1 REF: 411
- ANS: F PTS: 1 REF: 411
Outside classes should only be allowed to make a request that an attribute be altered; then it is up to the class’s methods to determine whether the request is appropriate. When using a door, you usually are unconcerned with the latch or hinge construction features, and you don’t have access to the interior workings of the knob or know what color of paint might have been used on the inside of the door panel. You care only about the functionality and the interface, the user-friendly boundary between the user and internal mechanisms of the device. Similarly, the detailed workings of objects you create within object-oriented programs can be hidden from outside programs and modules if you want them to be. When the details are hidden, programmers can focus on the functionality and the interface, as people do with real-life objects.
PTS: 1 REF: 414 TOP: Critical Thinking
- List the three parts of a class definition.
ANS: A class definition can contain three parts:
- Every class has a name.
- Most classes contain data, although this is not required.
- Most classes contain methods, although this is not required.
PTS: 1 REF: 415 TOP: Critical Thinking
- Describe what class diagrams list by convention.
ANS: By convention, a class diagram lists the names of the data items first. Each name is followed by a colon and the data type. Similarly, method names are followed by their data types. Listing the names first emphasizes the purposes of the fields and methods more than their types.
PTS: 1 REF: 417 TOP: Critical Thinking
- Explain what private access means in object-oriented programming.
ANS: Object-oriented programmers usually specify that their data fields will have private access—that is, the data cannot be accessed by any method that is not part of the class.
PTS: 1 REF: 424 TOP: Critical Thinking
- List the two identifiers within a method that always mean exactly the same thing when you write an instance method in a class.
ANS: When you write an instance method in a class, the following two identifiers within the method always mean exactly the same thing:
- any field name defined in the class
- this, followed by a dot, followed by the same field name
PTS: 1 REF: 432 TOP: Critical Thinking
- Describe what happens any time a local variable in a method has the same identifier as a class field.
ANS:
Any time a local variable in a method has the same identifier as a class field, the class field is hidden. This applies whether the local variable is a passed parameter or simply one that is declared within the method. In these cases, you must use a this reference to refer to the class field.
PTS: 1 REF: 434 TOP: Critical Thinking
- Discuss nonstatic methods.
ANS: Nonstatic methods are methods that exist to be used with an object. These instance methods receive a this reference to a specific object. In most programming languages, you use the word static when you want to declare a static class member, but you do not use a special word when you want a class member to be nonstatic. In other words, methods in a class are nonstatic instance methods by default.
PTS: 1 REF: 435 TOP: Critical Thinking