Podcast
Questions and Answers
Which part of an object exhibits its state?
Which part of an object exhibits its state?
- Operations
- Data (correct)
- Any private part
- Any public part
Inheritance is a way to
Inheritance is a way to
- pass arguments to objects of classes.
- organize data.
- add features to existing classes without rewriting them. (correct)
- improve data-hiding and encapsulation.
Suppose you have been given the following design:
"A person has a name, age, address and sex. You are designing a class to represent a type of person called a patient. This kind of person may be given a diagnosis, have a spouse and may be alive".
Given that the person class has already been created, what of the following would be appropriate to include when you design the patient class?
Suppose you have been given the following design: "A person has a name, age, address and sex. You are designing a class to represent a type of person called a patient. This kind of person may be given a diagnosis, have a spouse and may be alive". Given that the person class has already been created, what of the following would be appropriate to include when you design the patient class?
- sex and diagnosis
- age and sex
- diagnosis and age
- registration date and diagnosis (correct)
What problem(s) may occur when we copy objects without using deep copy constructor?
What problem(s) may occur when we copy objects without using deep copy constructor?
This pointers are not accessible for static member functions.
This pointers are not accessible for static member functions.
A static member function cannot be declared.
A static member function cannot be declared.
Remain in memory even when all objects of a class have been destroyed.
Remain in memory even when all objects of a class have been destroyed.
Friend functions are functions of a class.
Friend functions are functions of a class.
Which means if A declares B as its friend it DOES NOT mean that A can access private data of B. It only means that B can access all data of A.
Which means if A declares B as its friend it DOES NOT mean that A can access private data of B. It only means that B can access all data of A.
The statement objA=objB; will cause a compiler error if the objects are of different classes.
The statement objA=objB; will cause a compiler error if the objects are of different classes.
Which operator can not be overloaded?
Which operator can not be overloaded?
To convert from a user-defined class to a basic type, you would most likely use
To convert from a user-defined class to a basic type, you would most likely use
The technique in which we visualize our programming problems according to real life's problems is called
The technique in which we visualize our programming problems according to real life's problems is called
In object orientated programming, a class of objects can properties from another class of objects.
In object orientated programming, a class of objects can properties from another class of objects.
A C++ class is similar to
A C++ class is similar to
Suppose that the Test class does not have an overloaded assignment operator. What happens when an assignment a=b; is given for two Test objects a and b?
Suppose that the Test class does not have an overloaded assignment operator. What happens when an assignment a=b; is given for two Test objects a and b?
A'A static member function can be called, even when a class is not
A'A static member function can be called, even when a class is not
Identify which of the following overloaded operator function's declaration is appropriate for the given call?
Rational_number_1 + 2.325
Where Rational_number_1 is an object of user defined class Rational_number.
Identify which of the following overloaded operator function's declaration is appropriate for the given call? Rational_number_1 + 2.325 Where Rational_number_1 is an object of user defined class Rational_number.
Provide the facility to access the data member.
Provide the facility to access the data member.
Constant objects cannot change their state,
Constant objects cannot change their state,
Relationship indicates that an object contains other objects.
Relationship indicates that an object contains other objects.
Which one of the following features of OOP is used to derive a class from another?
Which one of the following features of OOP is used to derive a class from another?
Is a relationship
Is a relationship
Satisfy the condition of polymorphism
Satisfy the condition of polymorphism
A generalization-specialization relation between classes are implemented using
A generalization-specialization relation between classes are implemented using
The >= operator can be overloaded.
The >= operator can be overloaded.
In order to free the memory occupied by the object, we use
In order to free the memory occupied by the object, we use
Which of the following is not an example of multiple inheritances?
Which of the following is not an example of multiple inheritances?
Static variable can be initialized more than once.
Static variable can be initialized more than once.
A generic class showing all the common attributes and a behavior of other classes represents a very important feature in OOP called
A generic class showing all the common attributes and a behavior of other classes represents a very important feature in OOP called
We can get only one unique value which can be used by all the objects of that class by the use of,
We can get only one unique value which can be used by all the objects of that class by the use of,
A member function having the same name as that of a class and a ~ sign with it is called,
A member function having the same name as that of a class and a ~ sign with it is called,
Using encapsulation we can achieve
Using encapsulation we can achieve
For classes with common behavior, you can save effort by placing the common behavior in a
For classes with common behavior, you can save effort by placing the common behavior in a
Which of the following are an advantage of OOP?
Which of the following are an advantage of OOP?
Static variables act like a global variable in the context or scope of the class.
Static variables act like a global variable in the context or scope of the class.
The compiler won't object if you overload the * operator to perform division.
The compiler won't object if you overload the * operator to perform division.
We can use "this" pointer in the constructor in the body and even in the initialization list of any class if we are careful.
We can use "this" pointer in the constructor in the body and even in the initialization list of any class if we are careful.
An overloaded operator always requires one less argument than its number of operands.
An overloaded operator always requires one less argument than its number of operands.
In OOP a class is an example of
In OOP a class is an example of
A class can be identified from a statement by
A class can be identified from a statement by
The members of a class that can be accessed without creating the object of the class is called
The members of a class that can be accessed without creating the object of the class is called
Suppose there is an object of type Person, which of the following can be considered as one of its attributes
Suppose there is an object of type Person, which of the following can be considered as one of its attributes
What a derived class can add?
What a derived class can add?
Is/are used to access information hidden within an object?
Is/are used to access information hidden within an object?
Which one of the following terms best represents the statement given below, " Hiding details of an object from the other parts of a program"
Which one of the following terms best represents the statement given below, " Hiding details of an object from the other parts of a program"
Flashcards
What exhibits an object's state?
What exhibits an object's state?
The data portion of an object encompasses the properties and values that define its current state.
What is inheritance for?
What is inheritance for?
Inheritance allows you to create new classes (derived classes) that inherit properties and behaviors from existing classes (base classes) without rewriting them. This helps in code reuse and organization.
What would you include in a 'Patient' class derived from a 'Person' class?
What would you include in a 'Patient' class derived from a 'Person' class?
The Patient class would inherit from the Person class and add attributes specific to patients, such as diagnosis, registration date, and perhaps spouse information. Inheriting from Person avoids duplicating 'name', 'age', and 'sex' attributes.
What issues may occur when copying objects without a deep copy constructor?
What issues may occur when copying objects without a deep copy constructor?
Signup and view all the flashcards
Are 'this' pointers available for static member functions?
Are 'this' pointers available for static member functions?
Signup and view all the flashcards
What kind of function is not declared explicitly?
What kind of function is not declared explicitly?
Signup and view all the flashcards
What remains in memory even after destroying all objects of a class?
What remains in memory even after destroying all objects of a class?
Signup and view all the flashcards
Friend functions are ______________ functions of a class.
Friend functions are ______________ functions of a class.
Signup and view all the flashcards
How does friendship work between two classes?
How does friendship work between two classes?
Signup and view all the flashcards
What happens with object assignment if the objects are of different classes?
What happens with object assignment if the objects are of different classes?
Signup and view all the flashcards
What is the correct operator overloading declaration for adding a double to a class object?
What is the correct operator overloading declaration for adding a double to a class object?
Signup and view all the flashcards
Which operator cannot be overloaded?
Which operator cannot be overloaded?
Signup and view all the flashcards
How to convert from a user-defined class to a basic type?
How to convert from a user-defined class to a basic type?
Signup and view all the flashcards
What technique visualizes programming problems like real-life problems?
What technique visualizes programming problems like real-life problems?
Signup and view all the flashcards
What can a class of objects do with properties from another class in OOP?
What can a class of objects do with properties from another class in OOP?
Signup and view all the flashcards
What is a C++ class similar to?
What is a C++ class similar to?
Signup and view all the flashcards
What problem(s) may occur when copying objects without using a deep copy constructor?
What problem(s) may occur when copying objects without using a deep copy constructor?
Signup and view all the flashcards
What happens when assigning objects without an overloaded assignment operator?
What happens when assigning objects without an overloaded assignment operator?
Signup and view all the flashcards
When can a static member function be called?
When can a static member function be called?
Signup and view all the flashcards
What is the correct declaration for overloading the + operator to add a double to a class object?
What is the correct declaration for overloading the + operator to add a double to a class object?
Signup and view all the flashcards
What provides the facility to access data members?
What provides the facility to access data members?
Signup and view all the flashcards
Can constant objects change their state?
Can constant objects change their state?
Signup and view all the flashcards
What relationship indicates an object containing other objects?
What relationship indicates an object containing other objects?
Signup and view all the flashcards
Which OOP feature is used to derive a class from another?
Which OOP feature is used to derive a class from another?
Signup and view all the flashcards
What kind of relationship is inheritance?
What kind of relationship is inheritance?
Signup and view all the flashcards
What satisfies the condition of polymorphism?
What satisfies the condition of polymorphism?
Signup and view all the flashcards
How are generalization-specialization relations between classes implemented?
How are generalization-specialization relations between classes implemented?
Signup and view all the flashcards
Can the >= operator be overloaded?
Can the >= operator be overloaded?
Signup and view all the flashcards
What is used to free memory occupied by an object?
What is used to free memory occupied by an object?
Signup and view all the flashcards
What is not an example of multiple inheritances?
What is not an example of multiple inheritances?
Signup and view all the flashcards
Can a static variable be initialized more than once?
Can a static variable be initialized more than once?
Signup and view all the flashcards
What does a generic class representing common attributes and behavior of other classes represent?
What does a generic class representing common attributes and behavior of other classes represent?
Signup and view all the flashcards
Where do static variables act like global variables?
Where do static variables act like global variables?
Signup and view all the flashcards
Will the compiler object if the overloaded * operator is used for division?
Will the compiler object if the overloaded * operator is used for division?
Signup and view all the flashcards
Can the 'this' pointer be used within the constructor?
Can the 'this' pointer be used within the constructor?
Signup and view all the flashcards
What is a C++ class similar to?
What is a C++ class similar to?
Signup and view all the flashcards
Which operator can not be overloaded?
Which operator can not be overloaded?
Signup and view all the flashcards
How many arguments does an overloaded operator require?
How many arguments does an overloaded operator require?
Signup and view all the flashcards
How are generalization-specialization relations between classes implemented?
How are generalization-specialization relations between classes implemented?
Signup and view all the flashcards
In OOP, a class is an example of _____
In OOP, a class is an example of _____
Signup and view all the flashcards
How can a class be identified from a statement?
How can a class be identified from a statement?
Signup and view all the flashcards
What kind of class member can be accessed without creating an object?
What kind of class member can be accessed without creating an object?
Signup and view all the flashcards
What can be considered as one of an object's attributes?
What can be considered as one of an object's attributes?
Signup and view all the flashcards
What can a derived class add?
What can a derived class add?
Signup and view all the flashcards
What is/are used to access information hidden within an object?
What is/are used to access information hidden within an object?
Signup and view all the flashcards
Are 'this' pointers accessible for static member functions?
Are 'this' pointers accessible for static member functions?
Signup and view all the flashcards
What kind of function cannot be declared?
What kind of function cannot be declared?
Signup and view all the flashcards
Does the C++ compiler allow for dynamic allocation of memory for objects?
Does the C++ compiler allow for dynamic allocation of memory for objects?
Signup and view all the flashcards
How to improve the 'Base' class with respect to accessing the field 'Age'?
How to improve the 'Base' class with respect to accessing the field 'Age'?
Signup and view all the flashcards
Can friend classes and friend functions be used as alternatives?
Can friend classes and friend functions be used as alternatives?
Signup and view all the flashcards
Which operators always take no arguments if overloaded?
Which operators always take no arguments if overloaded?
Signup and view all the flashcards
What happens when assigning objects without an overloaded assignment operator?
What happens when assigning objects without an overloaded assignment operator?
Signup and view all the flashcards
What must an overloaded '-' operator do to work correctly?
What must an overloaded '-' operator do to work correctly?
Signup and view all the flashcards
Which operator can not be overloaded?
Which operator can not be overloaded?
Signup and view all the flashcards
How do we achieve independence of internal implementation from its external interface?
How do we achieve independence of internal implementation from its external interface?
Signup and view all the flashcards
Which one is not an object association?
Which one is not an object association?
Signup and view all the flashcards
How do we capture object attributes and behavior in OOP?
How do we capture object attributes and behavior in OOP?
Signup and view all the flashcards
What is the return type of a constructor?
What is the return type of a constructor?
Signup and view all the flashcards
Study Notes
CS304 - Object Oriented Programming Midterm Solved MCQs
-
Question 1 (Marks: 1): Which part of an object exhibits its state?
- Data (Page 23)
-
Question 2 (Marks: 1): Inheritance is a way to:
- add features to existing classes without rewriting them (Page 27)
-
Question 3 (Marks: 1): What should be included in a 'Patient' class (already having a 'Person' class)?
- diagnosis and age
- age and sex
- sex and diagnosis
- registration date and diagnosis
-
Question 4 (Marks: 1): What problem(s) occur when copying objects without a deep copy constructor?
- Dangling pointer
- Memory leakage
- All of the given (Page 147)
- System crash
-
Question 5 (Marks: 1): Are this pointers accessible for static member functions?
- False (Page 114)
-
Question 6 (Marks: 1): Can a static member function be declared?
- static
-
Question 7 (Marks: 1): What remains in memory even after all class objects are destroyed?
- Static variables (Page 111)
-
Question 8 (Marks: 1): What are friend functions?
- non-member functions of a class (Page 136)
-
Question 9 (Marks: 1): If A declares B as its friend, does A access B's private data?
- No, only B can access A's private data.
-
Question 10 (Marks: 1): Does objA=objB; cause a compiler error with different classes?
- True
-
Question 11 (Marks: 1): Which overloaded operator declaration is appropriate for Rational_number_1 + 2.325?
- Rational_number operator+(Rational_number& obj);
- Rational_number operator+(double& obj);
- Rational_number operator+(Rational_number &obj, double& num);
- operator+(double& obj);
-
Question 12 (Marks: 1): Which operator cannot be overloaded?
- Conditional operator (? :) (Page 141)
-
Question 13 (Marks: 1): How do you convert from user-defined class to basic types?
- Built-in conversion operator
-
Question 14 (Marks: 1): What is the programming technique that visualizes problems in real-world terms?
- Object Oriented Programming (Page 9)
-
Question 15 (Marks: 1): What can classes of objects do in OOP?
- Inherit properties from another class
-
Question 16 (Marks: 1): What is a C++ class similar to?
- Structure
-
Question 17 (Marks: 1): What happens when a=b; where 'a' and 'b' are Test objects but the Test class lacks an overloaded assignment operator?
- The automatic assignment operator is used.
-
Question 18 (Marks: 1): How can a class be identified in a statement?
-
Noun (Page 58)
-
Question 19 (Marks: 1): What are members that can be accessed without object creation?
- Public members
-
Question 20 (Marks: 1): What are attributes of a Person object?
- Name, Age
-
Question 21 (Marks: 1): What is/are used to access hidden information in an object?
- Private data members
- Private member functions (Page 69)
-
Question 22 (Marks: 1): Can this pointers be accessed with static member functions?
- False (Page 14)
-
Question 23 (Marks: 1): Can a static member function be declared?
-
Yes, a static member function can be declared.
-
Question 24 (Marks: 1): Can memory dynamically be allocated to objects in C++?
- False
-
Question 25 (Marks: 1): How can variable "Age" in class Base be accessed appropriately? -Define the variable Age as private and create a get method that returns it and a set method that updates it.
-
Question 26 (Marks: 1): What is not a keyword in C++?
-
B_op
-
operator
-
Question 27 (Marks: 1): Can the >= operator be overloaded?
- True (Page 140)
-
Question 28 (Marks: 1): How can a sub-object's life be independent of the master class's life?
- Composition
- Aggregation (Page 134)
-
Question 29 (Marks: 1): What is a way to make general classes more specific in OOP?
- Inheritance (Page 27)
-
Question 30 (Marks: 1): What is the return type of a constructor in C++ ?
- No type
-
Question 31 (Marks: 1): What is the process for hiding object details from users?
-
Encapsulation
-
Abstraction(Page 16)
-
Question 32 (Marks: 1): What are the ways to declare a variable to be static in class?
-
Static variable keyword before the variable declaration.
-
Question 33 (Marks: 1): Should static variables be initialized more than once?
- False (Page 107)
-
Question 34 (Marks: 1): What is the best approach to implement functions with identical behavior on different data types?
-
Templates
-
Overloading
-
Question 35 (Marks: 1): Is class Vector<char>* an example of partial specialization?
- True (Page 281)
-
**Question 36 (Marks: 1):**Classes like TwoDimensionalShape and ThreeDimensionalShape, should they be abstract?
-
True
-
Question 37 (Marks: 1): Classes like Sphere and Cube should they be abstract?
- True
-
Question 38 (Marks: 1): What is important in OOP for object identification?
- State, Behavior (and other properties)
-
Question 39 (Marks: 1): A member function that has the same name as the class and a '~' followed by the name is called?
- Destructor
-
Question 40 (Marks: 1): What is not an advantage of inheritance?
-
Avoiding code rewriting (and providing frameworks).
-
Expanding classes.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.