Podcast
Questions and Answers
Which part of an object exhibits its state?
Which part of an object exhibits its state?
Inheritance is a way to
Inheritance is a way to
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?
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?
Signup and view all the answers
This pointers are not accessible for static member functions.
This pointers are not accessible for static member functions.
Signup and view all the answers
A static member function cannot be declared.
A static member function cannot be declared.
Signup and view all the answers
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.
Signup and view all the answers
Friend functions are functions of a class.
Friend functions are functions of a class.
Signup and view all the answers
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.
Signup and view all the answers
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.
Signup and view all the answers
Which operator can not be overloaded?
Which operator can not be overloaded?
Signup and view all the answers
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
Signup and view all the answers
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
Signup and view all the answers
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.
Signup and view all the answers
A C++ class is similar to
A C++ class is similar to
Signup and view all the answers
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?
Signup and view all the answers
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
Signup and view all the answers
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.
Signup and view all the answers
Provide the facility to access the data member.
Provide the facility to access the data member.
Signup and view all the answers
Constant objects cannot change their state,
Constant objects cannot change their state,
Signup and view all the answers
Relationship indicates that an object contains other objects.
Relationship indicates that an object contains other objects.
Signup and view all the answers
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?
Signup and view all the answers
Is a relationship
Is a relationship
Signup and view all the answers
Satisfy the condition of polymorphism
Satisfy the condition of polymorphism
Signup and view all the answers
A generalization-specialization relation between classes are implemented using
A generalization-specialization relation between classes are implemented using
Signup and view all the answers
The >= operator can be overloaded.
The >= operator can be overloaded.
Signup and view all the answers
In order to free the memory occupied by the object, we use
In order to free the memory occupied by the object, we use
Signup and view all the answers
Which of the following is not an example of multiple inheritances?
Which of the following is not an example of multiple inheritances?
Signup and view all the answers
Static variable can be initialized more than once.
Static variable can be initialized more than once.
Signup and view all the answers
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
Signup and view all the answers
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,
Signup and view all the answers
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,
Signup and view all the answers
Using encapsulation we can achieve
Using encapsulation we can achieve
Signup and view all the answers
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
Signup and view all the answers
Which of the following are an advantage of OOP?
Which of the following are an advantage of OOP?
Signup and view all the answers
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.
Signup and view all the answers
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.
Signup and view all the answers
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.
Signup and view all the answers
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.
Signup and view all the answers
In OOP a class is an example of
In OOP a class is an example of
Signup and view all the answers
A class can be identified from a statement by
A class can be identified from a statement by
Signup and view all the answers
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
Signup and view all the answers
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
Signup and view all the answers
What a derived class can add?
What a derived class can add?
Signup and view all the answers
Is/are used to access information hidden within an object?
Is/are used to access information hidden within an object?
Signup and view all the answers
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"
Signup and view all the answers
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.
Related Documents
Description
Test your knowledge with this midterm quiz on Object Oriented Programming for CS304. It covers key concepts such as inheritance, class structures, and memory management. Answer multiple-choice questions to assess your understanding of the subject.