1. (TCO 1) Which of the following statements is/are true? (Points : 2) A. An obj
ID: 3645648 • Letter: 1
Question
1. (TCO 1) Which of the following statements is/are true? (Points : 2)A. An object should be concerned about how another object performs its duties.
B. The words class and object can be used interchangeably in object-oriented programming.
C. The implementation details of a class must be visible, so that users of that class are aware of when a change occurred.
D. The state of an object is defined as the attributes and behaviors of that object.
All are true
None are true
Only A and C
2. (TCO 1) The components of a class are called the _____ of that class. (Points : 2)
elements
members
objects
properties
3. (TCO 1) A class is a _____, which encapsulates _____ and _____. (Points : 2)
programming language construct; attributes; behavior
field; objects; members
template; methods; behavior
All of the above
None of the above
4. (TCO 1) All objects of the same class _____ copy of the attributes and methods. (Points : 2)
always share a
have their own
don't receive a
pass other objects a
5. (TCO 1) Assume we have two objects of a class. How many copies of the class's attributes and methods exist in the instantiated objects? (Points : 2)
Only one copy, both objects always share it
Zero, the objects do not have attributes and methods
Two copies, each object has its own copy
Three copies
6. (TCO 1) Which of the following class relationships can be modeled through object-oriented programming? (Points : 2)
Is-a
Has-a
All of the above
None of the above
7. (TCO 1) Code reuse and the building of more complex systems are facilitated both through _____ and _____. (Points : 2)
data hiding; implementation
composition; inheritance
inheritance; messaging
None of the above
8. (TCO 1) C++ is a(n) _____ programming language. (Points : 2)
procedural
object-oriented
hybrid
structured
9. (TCO 1) Which of the following is a valid statement for a class definition in C++? (Points : 2)
class Animal { //code goes here }
Class Animal { //code goes here }
class Animal ( //code goes here )
Class Animal ( //code goes here )
10. (TCO 1) When you try to call a member function using an object, the object name with the _____ operator followed by the member function name syntax is usually used. (Points : 2)
scope resolution
dot
address
None of the above
11. (TCO 2) Only those class members that are presented to the users of the class are part of the ______ of the class. (Points : 2)
interface
implementation
constructors
superclass
12. (TCO 2) Only those class members which are part of the interface of the class should be declared as ______. (Points : 2)
open
banned
private
public
Explanation / Answer
1.
It is not necessary for an object to be concerned about how another object performs its duties. Option A is not true.
A class is a user defined data type which consists of data and functions. An object is an instance of a class. The words class and object cannot be used interchangeably in object-oriented programming. Option B is not true.
Implementation details should be hidden from the user. Option C is not true.
An object is an instance of a class. The state of an object are the instance variables or attributes of the object. Option D is not true.
The correct option is None are true.
2.
A class is a user defined data type which consists of data and functions. Data of a class are also known as data members and functions of a class are known as members functions.
Hence, the components of a class are called the members of that class.
The correct option is members.
3.
A class is a programming language construct, which encapsulates attributes and function which describe the behaviour of the class.
The correct option is programming language construct; attributes; behaviour.
4.
An object is an instance of a class. When an object is created, it has its own copy of the attributes and methods. Thus, all objects of the same class have their own copy of the attributes and methods.
The correct option is have their own.
5.
An object is an instance of a class. When an object is created, it has its own copy of the attributes and methods. So, when two objects of a class is created, two copies of the class attributes and methods will exist.
The correct option is Two copies, each object has its own copy.
6.
In object-oriented programming, both Is-a and Has-a class relationships can be constructed.
Composition relationship between two classes can be represented as has-a relationship.
Inheritance between two classes can be represented as is-a relationship.
The correct option is All of the above.
7.
Inheritance refers to the process of creating a new class from an existing class. The new class is known as the derived class and existing class is known as base class. The derived class can inherit the properties and behaviour of the base class. Reusability of code is possible in inheritance.
Composition refers to the process of building complex systems using simpler ones.
Thus, code reuse and the building of more complex systems are facilitated both through composition and inheritance.
The correct option is composition; inheritance.
8.
C++ is a(n) object-oriented programming language.
The correct option is object-oriented.
9.
The declaration of a class is as follows:
class className
{
data members
member functions
};
Thus, the class Animal { //code goes here } is a valid statement for a class definition in C++.
The correct option is class Animal { //code goes here }.
10.
A member function of a class can be called using the object name followed by the dot operator followed by name of the member function.
Example: student.average(); where student is a object name and average is a member function.
The correct option is dot.
11.
Only those class members that are presented to the users of the class are part of the interface of the class.
Implementation details should be hidden from the user.
The correct option is interface.
12.
The member functions of a class which are part of the interface of the class should be declared as public.
The correct option is public.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.