1) Which of the following property is associated with objects?
a) State
b) Behavior
c) Identity
d) All of the mentioned
View Answer
Explanation: An object has state, exhibits some well defined behavior, and has a unique identity.
2) Which of the property of a object encompasses all of the (usually static) properties of the object plus the current (usually dynamic) values of each of these.
a) Semantics
b) Behavior
c) State
d) Identity
View Answer
Explanation: None.
3) The following is an example of
Struct PersonnelRecord
{
char name[100];
int socialSecurityNumber;
char department[10];
float salary;
};
a) Objects
b) Class
c) Both a and b
d) None of the mentioned
View Answer
Explanation: The above declaration denotes a class, not an object, because it does not represent a specific instance. To declare objects of this class we usually write in the following way:
PersonnelRecord deb, dave, jim, tom;
Class declaration is almost similar to struct declaration except that in reality it uses a keyword ‘class’ in place of ‘struct.’
4) Which of the following object types are generally autonomous, meaning that they can exhibit some behavior without being operated upon by another object
a) Passive
b) Active
c) Both a and b
d) None of the mentioned
View Answer
Explanation: None.
5) A ________ is a description of a set of objects that share the same attributes, operations, relationships, and semantics.
a) Structure
b) Class
c) Constructor
d) Function
View Answer
Explanation: Classes are the most important building blocks of any object- oriented systems. Classes are used to capture the vocabulary of the system you are developing. Modeling a system involves identifying the things that are important to your particular view. Hence all the above mentioned properties would distinguish each class from one another.
6) A ________ is a special member function whose task is to initialize the objects of its class.
a) Constructor
b) Destructor
c) Selector
d) Iterator
View Answer
Explanation: Constructors are special because its name is same as the class name. The constructor is invoked whenever an object of its associated class is created. It is called constructor because it constructs the value of data members of the class.
7) Which of the following statements about a constructor is not true?
a) We cannot refer to their addresses.
b) They cannot be inherited, though a derived class can call the base class constructor.
c) An object with a constructor can be used as a member of a union.
d) Constructors cannot be virtual.
View Answer
Explanation: An object with a constructor cannot be used as a member of a union. A union is a limited form of the class type. It can contain access specifiers (public, protected, private), member data, and member functions, including constructors and destructors. It cannot contain virtual member functions or static data members. Default access of members in a union is public. A union cannot be used as a base class and cannot be derived from a base class. (same with the constructor too, constructor cannot be inherited, though a derived class can call the basic class constructor).
8) The constructors that can take arguments are called ___________
a) Default Constructor
b) Copy Constructor
c) Parameterized Constructor
d) Dynamic Constructor
View Answer
Explanation: In order to initialize the various data elements of different objects with different values when they are created parameterized constructors are used.
9) When an object is created and initialized at the same time, a _________ constructor gets called.
a) Inline Constructor
b) Copy Constructor
c) Default Constructor
d) Parameterized Constructor
View Answer
Explanation: A copy constructor takes reference to an object of the same class as itself as an argument.
10) Destructor is defined as _______
a) Const matrix X(m, n);
b) matrix:: ~matrix(){ }
c) matrix:: matrix(void)
d) matrix()
View Answer
Explanation: A destructor is used to destroy the objects that have been created by a constructor. Like a constructor, the destructor is a member function whose name is same as the class name but is preceded by a tilde.
Sanfoundry Global Education & Learning Series – Object Oriented System Design.
To practice all features of Object Oriented System Design, here is complete set on 1000+ Multiple Choice Questions and Answers on Object Oriented System Design.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]