CS304 – Object Oriented Programming: Midterm Important MCQs (399 Solved Questions)
Computer Science • Read every solved MCQ with its verified answer key directly on this page. Free, no login required.
All 664 Midterm Packs · CS304 Course Page · CS304 Subjective Pack (58 Q&As)
-
Which of the following is a strong relationship?
Topic: OOP Concepts, Classes & Objects
- Composition ✓ Correct answer
- Inheritance
- Association
- Polymorphism
-
Which part of an object exhibits its state?
Topic: OOP Concepts, Classes & Objects
- Data ✓ Correct answer
- Operations
- Any public part
- Any private part
-
this pointers are not accessible for static member functions.
Topic: OOP Concepts, Classes & Objects
- True ✓ Correct answer
- False
-
________ remain in memory even when all objects of a class have been destroyed.
Topic: OOP Concepts, Classes & Objects
- Static variables ✓ Correct answer
- Instance variable
- Primitive variables
- None of given
-
__________ is creating objects of one class inside another class.
Topic: OOP Concepts, Classes & Objects
- Association
- Inheritance
- Aggregation
- Composition ✓ Correct answer
-
We can get the address of a variable stored in a pointer using __________:
Topic: OOP Concepts, Classes & Objects
- :symbol ✓ Correct answer
- :: symbol
- ->symbol
- & symbol
-
Which of the following statement is NOT true about static variable of a class?
Topic: OOP Concepts, Classes & Objects
- They are created even when there is no object of a class.
- Static variable belongs to a particular instance of a class. ✓ Correct answer
- Static variable is initialized once only throughout the program.
- They remain in memory even when all Objects of a class are destroyed.
-
An instance of user defined type is called __________
Topic: OOP Concepts, Classes & Objects
- Object ✓ Correct answer
- Class
- Variable
- Program
-
If class B inherits from class A then it contains all characteristics of __________.
Topic: OOP Concepts, Classes & Objects
- Class B
- None of the given option
- Class A ✓ Correct answer
- No inheritance
-
Suppose there is an object of type Person, which of the following can be considered as one of its attributes
Topic: OOP Concepts, Classes & Objects
- Name
- Age
- Work()
- Both Name and Age ✓ Correct answer
-
Which of the following best describes relationship between Book and BookChapter classes?
Topic: OOP Concepts, Classes & Objects
- Association
- Inheritance
- Aggregation
- Composition ✓ Correct answer
-
Which of the following stores the address of a variable?
Topic: OOP Concepts, Classes & Objects
- Pointer ✓ Correct answer
- Function
- Destructor
- Constructor
-
Which of the following can be used as an alternative to static members?
Topic: OOP Concepts, Classes & Objects
- Local Variables
- Array of Objects
- Global Variables ✓ Correct answer
- Constant Variables
-
Composition is __________ and aggregation is ____________ relationship.
Topic: OOP Concepts, Classes & Objects
- Weak, Weak
- Weak, Strong
- Strong, Weak ✓ Correct answer
- Strong, Strong
-
Suppose "int a;" is a static data member of a class named test. Which of the following is the correct way of initializing the static variable outside the class test?
Topic: OOP Concepts, Classes & Objects
- test a = 0;
- int test::a = 0; ✓ Correct answer
- int test->a = 0;
- int a::test = 0;
-
Suppose we have a class named “Student”; which of the following statement is correctly declaring the pointer to the object for “Student” class?
Topic: OOP Concepts, Classes & Objects
- Student obj;
- Student &obj;
- Student *obj; ✓ Correct answer
- *Student obj;
-
If we extend our Object Oriented Model and the rest of model is not affected, this feature is called___________.
Topic: OOP Concepts, Classes & Objects
- Flexibility ✓ Correct answer
- Reusability
- Efficiency
- Consistency
-
Which of the following can be the behavior of an object "Usman"?
Topic: OOP Concepts, Classes & Objects
- Eat ✓ Correct answer
- Address
- Name
- Age
-
The sentence "Object Oriented Programming book in bookshelf" is an example of:
Topic: OOP Concepts, Classes & Objects
- Binary association
- Association
- Multiple association
- Aggregation ✓ Correct answer
-
In Object Oriented programming, objects communicate with each other through __________.
Topic: OOP Concepts, Classes & Objects
- Messages ✓ Correct answer
- Data members
- Voice chat
- Ports
-
__________ associates the objects of the exact three classes.
Topic: OOP Concepts, Classes & Objects
- Binary Association
- Two way Association
- Ternary Association ✓ Correct answer
- N-ary Association
-
There is/are ____ way(s) to create user defined types for objects in C++.
Topic: OOP Concepts, Classes & Objects
- two ✓ Correct answer
- three
- four
- one
-
Which of the following represents the two-way association?
Topic: OOP Concepts, Classes & Objects
- All types of data members
- Ternary Association
- Constructor of the class
- Employee works for the company ✓ Correct answer
-
How many objects of a given class may be constructed in an application?
Topic: OOP Concepts, Classes & Objects
- Data member which is common to all the objects of a class
- class name, attributes, operation
- as many as the application ask for ✓ Correct answer
- They remain in memory even when all Objects of a class are destroyed.
-
Which of the following keyword tells the compiler to substitute the code within the function definition for every instance of a function call?
Topic: OOP Concepts, Classes & Objects
- inline ✓ Correct answer
- data member, Member function
- Instance variable
- To increase code re-usability
-
All objects of same class has _______________ attributes.
Topic: OOP Concepts, Classes & Objects
- They remain in memory even when all Objects of a class are destroyed.
- same ✓ Correct answer
- Data member which is common to all the objects of a class
- class name, attributes, operation
-
Aggregation between objects shows that ____________
Topic: OOP Concepts, Classes & Objects
- objects have weak relationship ✓ Correct answer
- Strong, Weak
- Weak, Strong
- Data member which is common to all the objects of a class
-
How can we identify classes from a given problem statement?
Topic: OOP Concepts, Classes & Objects
- by extracting nouns from problem statement ✓ Correct answer
- To enhance the communication between classes
- none of the given option
- Data member which is common to all the classes in a program
-
Composition is a strong relationship because ______.
Topic: OOP Concepts, Classes & Objects
- Composed object can exist independently
- Objects have weak relationship
- Composed object cannot exist independently ✓ Correct answer
- It is a one-way relationship
-
The statement objA=objB; will cause a compiler error if the objects are of different classes.
Topic: OOP Concepts, Classes & Objects
- True ✓ Correct answer
- False
-
The technique in which we visualize our programming problems according to real life's problems is called .................
Topic: OOP Concepts, Classes & Objects
- structured programming
- object oriented Programming ✓ Correct answer
- procedural programming
- non of the given
-
In object orientated programming, a class of objects cans _____________ properties from another class of objects
Topic: OOP Concepts, Classes & Objects
- Utilize
- Borrow
- Inherit ✓ Correct answer
- Adopt
-
A C++ class is similar to --------------------
Topic: OOP Concepts, Classes & Objects
- Structure ✓ Correct answer
- Header File
- Library File
- None of the given
-
a’A static member function can be called, even when a class is not __________.
Topic: OOP Concepts, Classes & Objects
- Declared
- Define
- Instantiated ✓ Correct answer
- Called
-
Constant objects cannot change their state,
Topic: OOP Concepts, Classes & Objects
- True ✓ Correct answer
- False
-
The _________ relationship indicates that an object contains other objects.
Topic: OOP Concepts, Classes & Objects
- None of given ✓ Correct answer
- ‘has-a’
- ‘is-a’
- ‘be-
-
Static variables act like a global variable in the context or scope of the class.
Topic: OOP Concepts, Classes & Objects
- True ✓ Correct answer
- False
-
In OOP a class is an example of ______ .
Topic: OOP Concepts, Classes & Objects
- Data Type
- Abstract Type
- User Defined Type ✓ Correct answer
- None of the given
-
________ is/are used to access information hidden within an object?
Topic: OOP Concepts, Classes & Objects
- Interface
- Private data members
- Private member functions ✓ Correct answer
- Both public and private members
-
Given the following class class Base{ int Age=33; } How you can improve above class with respect to accessing the field Age?
Topic: OOP Concepts, Classes & Objects
- Define the variable Age as private
- Define the variable Age as protected
- Define the variable Age as private and create a get method that returns it and a set method that updates it ✓ Correct answer
- Define the variable Age as protected and create a set method that returns it and a get method that updates it
-
The life of sub object is not dependant on the life of master class in ____________.
Topic: OOP Concepts, Classes & Objects
- Composition
- Aggregation ✓ Correct answer
- Separation
- None of the given
-
Which of the following statement is TRUE about a class's Static Member Function?
Topic: OOP Concepts, Classes & Objects
- It can access non-static data members.
- It is used to access static data members only. ✓ Correct answer
- It can only be called by a particular object of class.
- It can access constant data members of the class.
-
Which of the following is the correct syntax of declaring static variable “count” of type int?
Topic: OOP Concepts, Classes & Objects
- int static count;
- int count static;
- static count int;
- static int count; ✓ Correct answer
-
Which of the following creates the strongest relationship between two objects?
Topic: OOP Concepts, Classes & Objects
- Association
- Inheritance
- Composition ✓ Correct answer
- Aggregation
-
Static data members are shared by _____ of the class.
Topic: OOP Concepts, Classes & Objects
- Public data members
- All types of data members ✓ Correct answer
- Private data members
- Protected data members
-
Interaction of different objects in OO model is known as _______.
Topic: OOP Concepts, Classes & Objects
- Encapsulation
- Abstraction
- Association ✓ Correct answer
- Inheritance
-
Which of the following can be the attribute of the Employee class?
Topic: OOP Concepts, Classes & Objects
- Roll Number
- Course
- Salary ✓ Correct answer
- GPA
-
Which of the following offers a programmer the facility of using a specific class object into other classes?
Topic: OOP Concepts, Classes & Objects
- Inheritance
- Polymorphism
- Composition ✓ Correct answer
- Abstraction
-
Which of the following best defines static data members of a class?
Topic: OOP Concepts, Classes & Objects
- Data member which is allocated for each object separately
- Data member with global scope
- Data member which is common to all the classes in a program
- Data member which is common to all the objects of a class ✓ Correct answer
-
Following code is equivalent to which option.
Topic: OOP Concepts, Classes & Objects
- class Shape { public: string type; };
- class Shape { private: string type; }; ✓ Correct answer
- class Shape { protected: string type; };
- class Shape public: { public: string type; };
-
Consider the following class A{int a,b,c; public: A():B(10),C(0)a(7) };
Topic: OOP Concepts, Classes & Objects
- Concrete Class
- Class B
- Derived Class
- A,b,c ✓ Correct answer
-
Class is a blue print of
Topic: OOP Concepts, Classes & Objects
- Objects ✓ Correct answer
- facilitating class libraries.
- Whole, part
- Polymorphism
-
Which of the following Depicts the proper definition of class?
Topic: OOP Concepts, Classes & Objects
- They are created even when there is no object of a class.
- It can only be called by a particular object of class.
- a class is description of a kind of object ✓ Correct answer
- It can access constant data members of the class.
-
Entities in OO model are represented by
Topic: OOP Concepts, Classes & Objects
- polymorphism
- C1*c2
- global
- Rectangle ✓ Correct answer
-
---- is the relationship between the part object and the whole object
Topic: OOP Concepts, Classes & Objects
- a class is description of a kind of object
- both states and attributes of an object
- Composition ✓ Correct answer
- Any private part
-
which of the following classes are used by amphibious vehicle to inherit characteristics
Topic: OOP Concepts, Classes & Objects
- To use the functionality of one class into derived classes
- Both public and private members
- both states and attributes of an object
- both land and water vehicle ✓ Correct answer
-
object data includes
Topic: OOP Concepts, Classes & Objects
- Data member which is allocated for each object separately
- Both public and private members
- a class is description of a kind of object
- both states and attributes of an object ✓ Correct answer
-
which of the following is part of the Class diagram
Topic: OOP Concepts, Classes & Objects
- They remain in memory even when all Objects of a class are destroyed.
- all of the given option ✓ Correct answer
- nested class
- Data member which is common to all the objects of a class
-
Which one is not the main features of object oriented programming?
Topic: OOP Concepts, Classes & Objects
- exception handling ✓ Correct answer
- They are created even when there is no object of a class.
- a one-argument constructor.
- To use the functionality of one class into derived classes
-
static data member is declared
Topic: OOP Concepts, Classes & Objects
- data member, Member function
- static data members
- inside the class ✓ Correct answer
- Data member which is common to all the objects of a class
-
Which of the following can we attribute of an object "Ali"?
Topic: OOP Concepts, Classes & Objects
- both states and attributes of an object
- a class is description of a kind of object
- Data member which is allocated for each object separately
- address ✓ Correct answer
-
how many objects are involved in the binary Association
Topic: OOP Concepts, Classes & Objects
- 2 ✓ Correct answer
- 1
- 4
- 3
-
which of the following will happen when a constant function tried to change the value of data members of the class
Topic: OOP Concepts, Classes & Objects
- It can access constant data members of the class.
- Public data members
- it is used to access static data members
- compile time error will occur ✓ Correct answer
-
How the information hidden within an object can be accessed?
Topic: OOP Concepts, Classes & Objects
- They are created even when there is no object of a class.
- through its interface ✓ Correct answer
- information hiding
- It can only be called by a particular object of class.
-
object orientation approach can be achieved using object and their-------
Topic: OOP Concepts, Classes & Objects
- Data member which is allocated for each object separately
- a class is description of a kind of object
- It can only be called by a particular object of class.
- interactions ✓ Correct answer
-
memory is allocated to non-static members only when
Topic: OOP Concepts, Classes & Objects
- Static typing
- Static memory allocation
- object is created ✓ Correct answer
- private members of Derv.
-
in class B inherit from class A which of the following is child class
Topic: OOP Concepts, Classes & Objects
- class B ✓ Correct answer
- Constructor
- ‘has-a’
- Consistency
-
Consider the statement" room has chair" which of the following type of Association exists between whom and chair?
Topic: OOP Concepts, Classes & Objects
- To enhance the communication between classes
- aggregation ✓ Correct answer
- Two way Association
- by extracting nouns from problem statement
-
which of the following is a tangible entity
Topic: OOP Concepts, Classes & Objects
- Polymarphism
- encapsulation
- Car ✓ Correct answer
- Static typing
-
data member(s) of a class Student can be
Topic: OOP Concepts, Classes & Objects
- Data member with global scope
- Data member which is common to all the objects of a class
- All of the given options ✓ Correct answer
- All types of data members
-
Class diagram include
Topic: OOP Concepts, Classes & Objects
- both states and attributes of an object
- Destructor of the class
- class name, attributes, operation ✓ Correct answer
- a class is description of a kind of object
-
through interface was access objects------ --
Topic: OOP Concepts, Classes & Objects
- through its interface
- objects have week relationship
- behavior ✓ Correct answer
- It is used to access static data members only.
-
in class attributes and behaviors are represented by---- and--- respectively
Topic: OOP Concepts, Classes & Objects
- It can access constant data members of the class.
- data members, member functions ✓ Correct answer
- Data member which is common to all the objects of a class
- All types of data members
-
a class defined within another class is
Topic: OOP Concepts, Classes & Objects
- Abstract Class
- class B
- Destructor of the class
- nested class ✓ Correct answer
-
the compiler treats the Member function of a class as
Topic: OOP Concepts, Classes & Objects
- Data member which is common to all the objects of a class
- a conversion operator that’s a member of the class.
- inline function ✓ Correct answer
- data member, Member function
-
an object has attributes operation ,and--- ----
Topic: OOP Concepts, Classes & Objects
- class name, attributes, operation
- unique identity ✓ Correct answer
- both states and attributes of an object
- They are created even when there is no object of a class.
-
the car is composed of wheels what is the relationship between car and wheels?
Topic: OOP Concepts, Classes & Objects
- address
- To enhance the communication between classes
- objects have week relationship
- composition ✓ Correct answer
-
which of the following can be created without any object of a class?
Topic: OOP Concepts, Classes & Objects
- Data member which is allocated for each object separately
- They are created even when there is no object of a class.
- a class is description of a kind of object
- static data members ✓ Correct answer
-
member functions defined inside a class declaration are------- by default
Topic: OOP Concepts, Classes & Objects
- private ✓ Correct answer
- Static member function
- Static data member
- Protected
-
this pointer cannot be passed implicitly to-------- functions
Topic: OOP Concepts, Classes & Objects
- Member functions can be made private
- static member ✓ Correct answer
- initialize data member
- functions and classes
-
relationship in which child object gets destroyed if parent object is destroyed
Topic: OOP Concepts, Classes & Objects
- Data member which is allocated for each object separately
- They remain in memory even when all Objects of a class are destroyed.
- composition ✓ Correct answer
- It can only be called by a particular object of class.
-
object oriented programming is better than procedural programming because:
Topic: OOP Concepts, Classes & Objects
- a class is description of a kind of object
- Data member which is allocated for each object separately
- both states and attributes of an object
- it is more close to reality ✓ Correct answer
-
A good model is------ related to life problem
Topic: OOP Concepts, Classes & Objects
- Function definition
- Destructor
- closely ✓ Correct answer
- Semi colon
-
in constant Member function the type of this pointer is
Topic: OOP Concepts, Classes & Objects
- Data members can't be inherited
- The compiler can only generate copy for the int type data
- initialize data member
- constant pointer to constant data ✓ Correct answer
-
----- is set of function of an object exposed of other objects
Topic: OOP Concepts, Classes & Objects
- interface ✓ Correct answer
- inline function
- It can only be called by a particular object of class.
- They remain in memory even when all Objects of a class are destroyed.
-
a fan has wings, which type of relation exists between fan and Wings in this sentence
Topic: OOP Concepts, Classes & Objects
- Friend Class
- composition ✓ Correct answer
- State
- To enhance the communication between classes
-
which of the following statement is true about static function of a class
Topic: OOP Concepts, Classes & Objects
- All types of data members
- it is used to access static data members ✓ Correct answer
- Protected data members
- data members, member functions
-
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?
Topic: OOP Concepts, Classes & Objects
- registration date and diagnosis ✓ Correct answer
- age and sex
- sex and diagnosis
- diagnosis and age
-
Static variable can be initialized more than once.
Topic: OOP Concepts, Classes & Objects
- True ✓ Correct answer
- False
-
We can get only one unique value which can be used by all the objects of that class by the use of,
Topic: OOP Concepts, Classes & Objects
- static variables ✓ Correct answer
- dynamic variables
- instance variables
- data members
-
Static variable can be initialized more than once. True False (Page 107)
Topic: OOP Concepts, Classes & Objects
- True
- False ✓ Correct answer
-
A class can be identified from a statement by -------------
Topic: OOP Concepts, Classes & Objects
- Noun ✓ Correct answer
- Pronoun
- Verb
- Adverb
-
The members of a class that can be accessed without creating the object of the class is called
Topic: OOP Concepts, Classes & Objects
- Private member
- Data Member
- Public Member
- Static ✓ Correct answer
-
C++ compiler does not allow to dynamically allocate memory for objects
Topic: OOP Concepts, Classes & Objects
- False ✓ Correct answer
- True
-
Your chief Software designer has shown you a sketch of the new Computer parts system she is about to create. At the top of the hierarchy is a Class called Computer and under this are two child classes. One is called LinuxPC and one is called WindowsPC. The main difference between the two is that one runs the Linux operating System and the other runs the Windows System (of course another difference is that one needs constant re-booting and the other runs reliably). Under the WindowsPC are two Sub classes one called Server and one Called Workstation. How might you appraise your designers work?
Topic: OOP Concepts, Classes & Objects
- Give the goahead for further design using the current scheme
- Ask for a re-design of the hierarchy with changing the Operating System to a field rather than Class type ✓ Correct answer
- Ask for the option of WindowsPC to be removed as it will soon be obsolete
- Change the hierarchy to remove the need for the superfluous Computer Class.
-
When a variable is define as static in a class then all object of this class,
Topic: OOP Concepts, Classes & Objects
- Have different copies of this variable
- Have same copy of this variable ✓ Correct answer
- Can not access this variable
- None of given
-
A template provides a convenient way to make a family of
Topic: OOP Concepts, Classes & Objects
- variables and data members
- functions and classes ✓ Correct answer
- classes and exceptions
- programs and algorithms
-
Classes like TwoDimensionalShape and ThreeDimensionalShape would normally be concrete, while classes like Sphere and Cube would normally be abstract.
Topic: OOP Concepts, Classes & Objects
- True
- False ✓ Correct answer
-
In order to define a class template, the first line of definition must be:
Topic: OOP Concepts, Classes & Objects
- template <typename T> ✓ Correct answer
- typename <template T>
- Template Class <ClassName>
- Class <Template T>
-
Which of the following may not be an integral part of an object?
Topic: OOP Concepts, Classes & Objects
- State
- Behavior
- Protected data members ✓ Correct answer
- All of given
-
We can access a private static data member of a class through _________________.
Topic: OOP Concepts, Classes & Objects
- Static data member ✓ Correct answer
- Global data member
- Static member function
- Global member function
-
If you do not initialize static data member of a class of int type, it is automatically initialized with _________.
Topic: OOP Concepts, Classes & Objects
- 0 ✓ Correct answer
- 1
- Null
- -32767
-
Which of the following is used to perform some useful work between object in OOP?
Topic: OOP Concepts, Classes & Objects
- aggregation
- inheritance
- encapsulation
- association ✓ Correct answer
-
How many types of Association is OOP?
Topic: OOP Concepts, Classes & Objects
- 1
- 2 ✓ Correct answer
- 3
- 4
-
Suppose there is an object of type Class, which of the following can be considered as one of its function
Topic: OOP Concepts, Classes & Objects
- changeName ( );
- changeSection ( );
- changeIncharge ( );
- All of the given ✓ Correct answer
-
The relationship between container and contained objects is called ____________.
Topic: OOP Concepts, Classes & Objects
- Association
- Aggregation ✓ Correct answer
- Inheritance
- Composition
-
Why do we need relationships between classes?
Topic: OOP Concepts, Classes & Objects
- To increase code re-usability
- All of the given option ✓ Correct answer
- To use the functionality of one class into derived classes
- To enhance the communication between classes
-
Which of the following keyword should be used to declare a static variable?
Topic: OOP Concepts, Classes & Objects
- stat
- global
- const
- static ✓ Correct answer
-
In OOP, static data members of a class are called ______________ variables.
Topic: OOP Concepts, Classes & Objects
- Class ✓ Correct answer
- Object
- Structure
- Function
-
Which of the following class cannot exist standalone in an object model?
Topic: OOP Concepts, Classes & Objects
- Concrete Class
- Abstract Class ✓ Correct answer
- Friend Class
- Derived Class
-
What will be the value of variables a,b, and c after instantiating an object of the given class?
Topic: OOP Concepts, Classes & Objects
- 5, 5, 5
- Junk value, 5, Junk value ✓ Correct answer
- 5, Junk value, 5
- Junk value, 5, 5
-
Suppose we have a class named "Test" and void show() is one of its public member function. Which of the following is a correct way to call show() function using Test pointer ptr?
Topic: OOP Concepts, Classes & Objects
- ptr:show(); ✓ Correct answer
- ptr::show();
- ptr.show();
- ptr ->show();
-
"Static data member is declared ___ the class, but they are defined ___ the class."
Topic: OOP Concepts, Classes & Objects
- Outside, Outside
- Outside, Inside
- Inside, Inside
- Inside, Outside ✓ Correct answer
-
Consider the following code and choose the correct order of initialization for the data members of the class.
Topic: OOP Concepts, Classes & Objects
- a,c,b
- c,a,b
- a,b,c ✓ Correct answer
- b,a,c
-
Which of the following is a weak relationship?
Topic: OOP Concepts, Classes & Objects
- Aggregation
- Association ✓ Correct answer
- Composition
- Inheritance
-
A doctor can see patients. This type of relationship is known as _________.
Topic: OOP Concepts, Classes & Objects
- Binary Association
- Two-way Association
- One-way Association ✓ Correct answer
- Ternary Association
-
"Static data member is declared ___ the class, but they are defined ___ the class." Choose the correct sequence of data member declaration and definition.
Topic: OOP Concepts, Classes & Objects
- Outside, Outside
- Outside, Inside
- Inside, Inside
- Inside, Outside ✓ Correct answer
-
Consider the following code and choose the correct order of initialization for the data members of the class. class A { int a,b,c; public: A(): b(10), c(0), a(7){ } };
Topic: OOP Concepts, Classes & Objects
- a,c,b
- c,a,b
- a,b,c ✓ Correct answer
- b,a,c
-
Through ___________, Objects communicate with outer world.
Topic: OOP Concepts, Classes & Objects
- Polymorphism
- Interface ✓ Correct answer
- Encapsulation
- Inheritance
-
Static data members are called __________ variables.
Topic: OOP Concepts, Classes & Objects
- Class ✓ Correct answer
- Structure
- Object
- None of the given
-
Through interface we represent object's _________________.
Topic: OOP Concepts, Classes & Objects
- through its interface
- a class is description of a kind of object
- Behaviour ✓ Correct answer
- It can only be called by a particular object of class.
-
"Student registers Course and Teacher teaches the Course." is an example of ____________.
Topic: OOP Concepts, Classes & Objects
- Single inheritance
- protected members of Derv.
- Multiple association
- Binary Association ✓ Correct answer
-
In composition ____________ are called from composing objects to composed objects.
Topic: Constructors & Destructors
- Pointers
- Destructors ✓ Correct answer
- Constructors
- Member Functions
-
Destructor is a function which has the same name as that of class, but starts with a ____________ sign.
Topic: Constructors & Destructors
- $
- ~ ✓ Correct answer
- #
- %
-
What problem(s) may occur when we copy objects without using deep copy constructor?
Topic: Constructors & Destructors
- Dangling pointer
- Memory Leakage
- All of the given ✓ Correct answer
- System crash
-
Copy constructor is called when:
Topic: Constructors & Destructors
- An object is deleted.
- An object is created.
- An array of objects is created.
- An object is created in term of pre existing object. ✓ Correct answer
-
Constructors have _____ return type.
Topic: Constructors & Destructors
- int
- no ✓ Correct answer
- char
- void
-
How can we differentiate between constructors and destructors?
Topic: Constructors & Destructors
- Destructors are exactly same as Constructors in syntax.
- Destructors can't be defined by the programmer, but Constructors can be defined by the programmer.
- Destructors have a return type but Constructors do not have return type.
- Destructors are preceded with a tilde (~) symbol, and Constructors are not preceded with any symbol. ✓ Correct answer
-
Constructor without any parameter is called ____________________.
Topic: Constructors & Destructors
- constructor is used to initialize the data members of a class
- Constructor does not have return type
- Constructor can be a constant function
- Default constructor ✓ Correct answer
-
In order to free the memory occupied by the object, we use ____________ .
Topic: Constructors & Destructors
- Constructor
- Destructor ✓ Correct answer
- Shallow Copy
- Deep Copy
-
We can use "this" pointer in the constructor in the body and even in the initialization list of any class if we are careful,
Topic: Constructors & Destructors
- True
- False ✓ Correct answer
-
which of the following define default constructor 5 class student
Topic: Constructors & Destructors
- student(){//..} ✓ Correct answer
- Constructor can be a constant function
- compiler will call implicit default constructor
- constructor is used to initialize the data members of a class
-
compiler generated defaulter structure is called----- hand user written default constructor is called----
Topic: Constructors & Destructors
- Constructor does not have return type
- compiler will call implicit default constructor
- Constructor can be a constant function
- implicit, explicit ✓ Correct answer
-
Suppose a class does not have any constructor what will happen when an object of this class is created?
Topic: Constructors & Destructors
- compiler will call implicit default constructor ✓ Correct answer
- An object is created in term of pre existing object.
- Constructor is used to initialize data members of a class.
- An object is created.
-
when an object is initialized, is automatically called by the compiler
Topic: Constructors & Destructors
- constructor ✓ Correct answer
- all of the given option
- An object is created.
- An object is created in term of pre existing object.
-
which of the following statement best describes the constructor
Topic: Constructors & Destructors
- Default constructor
- Constructors are commonly public members of a class.
- compiler will call implicit default constructor
- constructor is used to initialize the data members of a class ✓ Correct answer
-
There are ------ types of constructor in C++
Topic: Constructors & Destructors
- 3 ✓ Correct answer
- compiler will call implicit default constructor
- Constructor is used to initialize data members of a class.
- Default constructor
-
suppose student is a class, which of the following defines constructor with one parameter for class student
Topic: Constructors & Destructors
- compiler will call implicit default constructor
- constructor is used to initialize the data members of a class
- student(char*aName); ✓ Correct answer
- Default constructor
-
Supposed derived class is inherited from base class what happens when a derived class object is created
Topic: Constructors & Destructors
- Constructor is used to initialize data members of a class.
- the constructor of base class exact is executed before the constructor of derived class ✓ Correct answer
- An object is created.
- An object is created in term of pre existing object.
-
which of the following is true about constructor
Topic: Constructors & Destructors
- Default constructor
- compiler will call implicit default constructor
- all of the given option ✓ Correct answer
- Constructor does not have return type.
-
A member function having the same name as that of a class and a ~ sign with it is called,
Topic: Constructors & Destructors
- Constructor
- Getter
- Setter
- Destructor ✓ Correct answer
-
Consider the code below, class Fred { public: Fred(); ... }; int main() { Fred a[10]; Fred* p = new Fred[10]; ... } Select the best option,
Topic: Constructors & Destructors
- Fred a[10]; calls the default constructor 09 times Fred* p = new Fred[10]; calls the default constructor 10 times
- Produce an error
- Fred a[10]; calls the default constructor 11 times Fred* p = new Fred[10]; calls the default constructor 11 times
- Fred a[10]; calls the default constructor 10 times Fred* p = new Fred[10]; calls the default constructor 10 times ✓ Correct answer
-
Which of the following is NOT true about constructor?
Topic: Constructors & Destructors
- Constructor is a special function having the same name as the class name
- Constructor does not have return type
- Constructors are commonly public members
- Constructor can be a constant function ✓ Correct answer
-
Which of the following is NOT true about constructor?
Topic: Constructors & Destructors
- Constructors are commonly public members of a class.
- Constructor is used to initialize data members of a class.
- Constructor is a special function which can have different name than class name. ✓ Correct answer
- Constructor does not have return type.
-
__________ is automatically called when the object is created.
Topic: Constructors & Destructors
- member function
- object
- constructor ✓ Correct answer
- None of the given
-
A class can have only ___________ destructor(s).
Topic: Constructors & Destructors
- 3
- One ✓ Correct answer
- Constructor is used to initialize data members of a class.
- Constructors are commonly public members of a class.
-
Inheritance is a way to
Topic: Inheritance
- organize data.
- pass arguments to objects of classes.
- add features to existing classes without rewriting them. ✓ Correct answer
- improve data-hiding and encapsulation.
-
Which of the following is not an example of multiple inheritances?----------
Topic: Inheritance
- Mermaid
- Woman ✓ Correct answer
- Amphibious Vehicle
- None of the given
-
The concept of derived classes is involved in,
Topic: Inheritance
- inheritance ✓ Correct answer
- encapsulation
- structure
- array
-
Which problem arises due to multiple inheritance, when the parent classes are also derived from the grandparent class?
Topic: Inheritance
- Circle
- Diamond ✓ Correct answer
- Triangle
- Loop
-
The process of extracting common characteristics from two or more classes and combining them into a generalized superclass is called ____________.
Topic: Inheritance
- Generalization ✓ Correct answer
- Specialization
- Abstraction
- Composition
-
Which one of the following features of OOP is used to derive a class from another?
Topic: Inheritance
- Encapsulation
- Polymorphism
- Data hiding
- Inheritance ✓ Correct answer
-
A generalization-specialization relation between classes are implemented using __________ .
Topic: Inheritance
- data hiding
- friend classes
- encapsulation
- inheritance ✓ Correct answer
-
What a derived class can add?
Topic: Inheritance
- New data members
- New member functions and New friend functions
- New constructors and destructor
- All of given ✓ Correct answer
-
Which one of the following is not an object association?
Topic: Inheritance
- Simple Assocation
- Inheritance ✓ Correct answer
- Aggregation
- Composition
-
In C++, Composition is a relationship between ____________ and _______________ objects.
Topic: Inheritance
- Whole, part ✓ Correct answer
- Parent, child
- Base, derived
- All given options are correct.
-
Which of the following method allows to reuse the characteristics of more than one parent class?
Topic: Inheritance
- Polymorphism
- Multiple Inheritance ✓ Correct answer
- Specialization
- Single inheritance
-
Generalization is implemented through:
Topic: Inheritance
- Polymorphism
- Composition
- Aggregation
- Inheritance ✓ Correct answer
-
In _______, Base class can't always be replaced by the derived class.
Topic: Inheritance
- specialization ✓ Correct answer
- Base, derived
- facilitating class libraries.
- protected members of Base.
-
____________ is a concept to extract common behaviours by using Bottom to Top approach.
Topic: Inheritance
- Generalization ✓ Correct answer
- Sub-typing
- Extension
- Specialization
-
In OOP, which of the following feature is used to derive a class from another class?
Topic: Inheritance
- Inheritance ✓ Correct answer
- Polymorphism
- Data hiding
- Encapsulation
-
--------------- represent "IS A" relationship
Topic: Inheritance
- Inheritance ✓ Correct answer
- Operator overloading
- User Defined Type
- friend
-
minimum classes required in a program for implementing multiple inheritance
Topic: Inheritance
- 1
- Single inheritance
- 3 ✓ Correct answer
- 0
-
in------- base class can be replaced by the derived class
Topic: Inheritance
- facilitating class libraries.
- protected members of Base.
- Base, derived
- extension ✓ Correct answer
-
inheritance is the relationship between
Topic: Inheritance
- classes ✓ Correct answer
- Sub-typing
- Single inheritance
- Polymarphism
-
inheritance is shown by
Topic: Inheritance
- filled arrow ✓ Correct answer
- protected
- Single inheritance
- virtual
-
generalization is-------- approach
Topic: Inheritance
- bottom-up ✓ Correct answer
- Vehicle
- Constructor
- specialization
-
the other name of specialization is-------
Topic: Inheritance
- restriction ✓ Correct answer
- Both Name and Age
- all of the given option
- Compatible
-
the other name of subtyping is
Topic: Inheritance
- Extension ✓ Correct answer
- Public members are accessible from other classes also
- Class
- Implicit
-
in generalization general class represents the -------- behavior of the class
Topic: Inheritance
- facilitating class libraries.
- Aggregation
- common ✓ Correct answer
- Loop
-
multiple inheritance is implemented between class through------ symbol
Topic: Inheritance
- int test::a = 0;
- comma(,) ✓ Correct answer
- Work()
- ptr:show();
-
_______ is a relationship
Topic: Inheritance
- Inheritance ✓ Correct answer
- Polymarphism
- abstraction
- encapsulation
-
A generic class showing all the common attributes and a behavior of other classes represents a very important feature in oop called --------
Topic: Inheritance
- Inheritance ✓ Correct answer
- Encapsulation
- Polymarphism
- Abstraction
-
template <> class Vector<char*> { } This is an example of partial specialization.
Topic: Inheritance
- True ✓ Correct answer
- False
-
Assume a class Derv that is privately derived from class Base. An object of class Derv located in main() can access
Topic: Inheritance
- public members of Derv. ✓ Correct answer
- protected members of Derv.
- private members of Derv.
- protected members of Base.
-
Which is not the Advantage of inheritance?
Topic: Inheritance
- providing class growth through natural selection.
- facilitating class libraries.
- avoiding the rewriting of code. ✓ Correct answer
- providing a useful conceptual framework.
-
What is the access specifier used to specify that the members of a base class are accessible in the derived class but not to the outside world?
Topic: Inheritance
- public
- private
- protected ✓ Correct answer
- friend
-
Car carries passengers. Bus carries passengers. Truck carries luggage. Harvester harvests the crops. Car, Bus, Harvester and Truck are derived from which class?
Topic: Inheritance
- Public Transport
- Passenger Transport
- Vehicle ✓ Correct answer
- Navy Ships
-
Specialization means that derived class is behaviorally __________ with the base class.
Topic: Inheritance
- Same
- Compatible
- Different
- Incompatible ✓ Correct answer
-
__________ is the reverse process of Generalization.
Topic: Inheritance
- Aggregation
- Inheritance
- Dependence
- Specialization ✓ Correct answer
-
In OOP, we can achieve reusability through __________.
Topic: Inheritance
- False
- Triangle
- Inheritance ✓ Correct answer
- receiver
-
Identify the abstract class from the given statement: "Vehicle class is base class. Bus, Car, and Truck are derived classes."
Topic: Inheritance
- Base, derived
- None of the given
- All of given
- Vehicle ✓ Correct answer
-
Mermaid is an example of _________.
Topic: Inheritance
- Overriding
- Single inheritance ✓ Correct answer
- Multiple association
- Whole, part
-
A static member function cannot be declared.
Topic: Polymorphism & Virtual Functions
- Static
- Implicit
- Explicit
- Virtual ✓ Correct answer
-
____________ satisfy the condition of polymorphism.
Topic: Polymorphism & Virtual Functions
- Carbon
- Diamond
- Coal
- all of the given ✓ Correct answer
-
in polymorphism messenger can be interpreted in different ways depending upon the----- class
Topic: Polymorphism & Virtual Functions
- 1
- facilitating class libraries.
- Triangle
- receiver ✓ Correct answer
-
In which of the following different forms office single entity exist?
Topic: Polymorphism & Virtual Functions
- Dynamic allocation
- composed object can not exist independently
- polymorphism ✓ Correct answer
- Single inheritance
-
polymorphism makes the system
Topic: Polymorphism & Virtual Functions
- all of the given option ✓ Correct answer
- protected members of Base.
- Binary Association
- None of the given
-
The derived class inherits behavior from the base class and also exhibits its own behavior. this concept is known as---
Topic: Polymorphism & Virtual Functions
- Base, derived
- facilitating class libraries.
- protected members of Base.
- Overriding ✓ Correct answer
-
Which one of the following terms must relate to polymorphism?
Topic: Polymorphism & Virtual Functions
- Static allocation
- Static typing
- Dynamic binding Click here for more detail ✓ Correct answer
- Dynamic allocation
-
A non-virtual member function is defined in a base class and overridden in a derived class; if that function is called through a base-class pointer to a derived class object, the derived-class version is used.
Topic: Polymorphism & Virtual Functions
- True
- False ✓ Correct answer
-
If there is a pointer p to objects of a base class, and it contains the address of an object of a derived class, and both classes contain a nonvirtual member function, ding(), then the statement p->ding(); will cause the version of ding() in the _____ class to be executed.
Topic: Polymorphism & Virtual Functions
- Base ✓ Correct answer
- Derived
- Abstract
- virtual
-
In which of the following OOP paradigm objects cannot exist independently?
Topic: Polymorphism & Virtual Functions
- Aggregation
- Inheritance
- Composition
- Polymorphism ✓ Correct answer
-
The keyword "friend" should be placed in ____________ :
Topic: Operator Overloading & Friend Functions
- Main Function
- Function Definition
- Anywhere in program
- Function Declaration ✓ Correct answer
-
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.
Topic: Operator Overloading & Friend Functions
- Rational_number operator+( Rational_number & obj);
- Rational_number operator+(double& obj); ✓ Correct answer
- Rational_number operator+(Rational_number &obj, double& num);
- operator+(double& obj);
-
Which operator can not be overloaded?
Topic: Operator Overloading & Friend Functions
- The relation operator ( >= )
- Assignment operator ( = )
- Script operator ( [] )
- Conditional operator (? : ) ✓ Correct answer
-
Which of the following operators operate on one operand?
Topic: Operator Overloading & Friend Functions
- Unary Operators ✓ Correct answer
- Ternary Operator
- Binary Operators
- All of the given options
-
The >= operator can be overloaded.
Topic: Operator Overloading & Friend Functions
- True ✓ Correct answer
- False
-
___________ Operator is used to create objects at run time.
Topic: Operator Overloading & Friend Functions
- New ✓ Correct answer
- Create
- Dynamic
- Subscript
-
Static Data Members can be accessed through _________.
Topic: Operator Overloading & Friend Functions
- Semi colon
- Dot operator
- Scope resolution operator
- Dot operator and scope resolution operator ✓ Correct answer
-
In expression b = c / d , the arity of division (/) operator is ________:
Topic: Operator Overloading & Friend Functions
- 1
- 4
- 2 ✓ Correct answer
- 3
-
In C++, which of the following is defined as stream insertion operator?
Topic: Operator Overloading & Friend Functions
- *<
- << ✓ Correct answer
- *>
- >>
-
Which of the following is an example of unary operator?
Topic: Operator Overloading & Friend Functions
- Division Operator ( / )
- Equality Operator ( = =)
- Inequality Operator ( != )
- Increment Operator ( ++ ) ✓ Correct answer
-
Which of the following issue(s) can be caused by the use of friend functions?
Topic: Operator Overloading & Friend Functions
- All of the given ✓ Correct answer
- Tough debugging
- Data vulnerability
- Programming bugs
-
cout is an object of _____ class.
Topic: Operator Overloading & Friend Functions
- istream
- instream
- fstream
- ostream ✓ Correct answer
-
Which of the following operator doesn't take any argument if overloaded?
Topic: Operator Overloading & Friend Functions
- !
- -
- +
- None of the given choices ✓ Correct answer
-
Statement "Yasir is a friend of Ali and Ali is a friend of Yasir" is an example of :
Topic: Operator Overloading & Friend Functions
- One way association
- Two way association ✓ Correct answer
- Ternary association
- N-ary association
-
We can allocate dynamic memory in C++ through __________ operator.
Topic: Operator Overloading & Friend Functions
- Static
- Const
- New ✓ Correct answer
- Global
-
Friend functions are _____________ functions of a class.
Topic: Operator Overloading & Friend Functions
- None of given
- object member
- non-member ✓ Correct answer
- data member
-
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?
Topic: Operator Overloading & Friend Functions
- The automatic assignment operator is used
- The copy constructor is used ✓ Correct answer
- Compiler error
- Run-time error
-
The compiler won’t object if you overload the * operator to perform division.
Topic: Operator Overloading & Friend Functions
- True ✓ Correct answer
- False
-
Which construct is the source for the creation of an object at runtime?
Topic: Operator Overloading & Friend Functions
- Destructor of the class
- New operator ✓ Correct answer
- Delete operator
- Constructor of the class
-
Which of the following is defined as stream extraction operator in C++?
Topic: Operator Overloading & Friend Functions
- *<
- <<
- *>
- >> ✓ Correct answer
-
What is the purpose of new operator?
Topic: Operator Overloading & Friend Functions
- Used as return type when an object is created
- Used to declare any new thing in a program
- Allocates memory for an object or array
- Allocates memory for an object or array and returns a particular pointer ✓ Correct answer
-
Which of the following is correct feature that is used to make basic operators like +, -, * and / etc. to work with user defined types?
Topic: Operator Overloading & Friend Functions
- type loading
- abstraction
- operator overloading ✓ Correct answer
- inheritance
-
A Post-fix unary operator is implemented in C ++ using Member function with
Topic: Operator Overloading & Friend Functions
- Non-member function, int
- 1 dummy int argument ✓ Correct answer
- Equality Operator: ==
- object member
-
choose correct declaration of overload*=1 operator for class complex as Member function
Topic: Operator Overloading & Friend Functions
- Stream Extraction Operator: >>
- Function Operator: ()
- Rational_number operator+( Rational_number & obj);
- Complex and operator*=(const complex & c) ✓ Correct answer
-
choose the correct declaration of overloaded equality (==)operator for class string as a Member function
Topic: Operator Overloading & Friend Functions
- Bool operator==(const string and s) ✓ Correct answer
- Function Operator: ()
- Complex operator + ::(const Complex & rhs);
- Rational_number operator+(double& obj);
-
choose correct declaration of overloaded inequality(!=) operator for class string as non member friend function
Topic: Operator Overloading & Friend Functions
- Rational_number operator+( Rational_number & obj);
- friend bool operator !=(const string &s1,const string &2) ✓ Correct answer
- Complex operator +(const Complex & rhs);
- Function Operator: ()
-
choose the correct option to declare an overloaded Stream insertion operator for 0304-1659294 userdefind class "string" as a non- member friend function
Topic: Operator Overloading & Friend Functions
- Complex and operator*=(const complex & c)
- friend ostream & operator<<(ostream and os,const string & s) ✓ Correct answer
- Stream Extraction Operator: >>
- operator + Complex (const Complex & rhs);
-
a post-fix unary operator implemented in C plus plus using non Member function with---- arguments
Topic: Operator Overloading & Friend Functions
- Dot operator
- two ✓ Correct answer
- Main Function
- Non-member function, char
-
what is the output of the following code int main(){int cost x=10;cout<<++x;return0;}
Topic: Operator Overloading & Friend Functions
- Member function, int
- Main Function
- error ✓ Correct answer
- Depends on code
-
----- define the order of evaluation of an operator is an expression
Topic: Operator Overloading & Friend Functions
- operator precedence ✓ Correct answer
- Ternary Operator
- Equality Operator: ==
- operator overloading
-
assignment operator are
Topic: Operator Overloading & Friend Functions
- Right to Right
- right associative ✓ Correct answer
- Dot operator
- The automatic assignment operator is used
-
___________, 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.
Topic: Operator Overloading & Friend Functions
- Friendship is one way only ✓ Correct answer
- Friendship is two way only
- NO Friendship between classes
- Any kind of friendship
-
To convert from a user-defined class to a basic type, you would most likely use
Topic: Operator Overloading & Friend Functions
- a built-in conversion operator.
- a one-argument constructor.
- an overloaded = operator.
- a conversion operator that’s a member of the class. ✓ Correct answer
-
For classes with common behavior, you can save effort by placing the common behavior in a __________.
Topic: Operator Overloading & Friend Functions
- Derived Class
- Base class ✓ Correct answer
- Deprived Class
- Named class
-
An overloaded operator always requires one less argument than its number of operands.
Topic: Operator Overloading & Friend Functions
- True ✓ Correct answer
- False
-
Friend class and friend function can be used as an alternate to each other
Topic: Operator Overloading & Friend Functions
- True ✓ Correct answer
- False
-
Which of the following operators always takes no argument if overloaded?
Topic: Operator Overloading & Friend Functions
- /
- -
- +
- ++ ✓ Correct answer
-
Assume a class C with objects obj1, obj2, and obj3. For the statement obj3 = obj1 - obj2 to work correctly, if the overloaded - operator must
Topic: Operator Overloading & Friend Functions
- take two arguments.
- return a value ✓ Correct answer
- create a named temporary object.
- take four arguments
-
When the base class and the derived class have a member function with the same name, you must be more specific which function you want to call (using ___________).
Topic: Operator Overloading & Friend Functions
- scope resolution operator
- dot operator
- null operator
- Operator overloading ✓ Correct answer
-
Non Template Friend functions of a class are friends of ________instance/s of that class.
Topic: Operator Overloading & Friend Functions
- All ✓ Correct answer
- One specific
- All instances of one date type
- None of the given options
-
What is the general syntax of overloading Unary Operator as member function of the class?
Topic: Operator Overloading & Friend Functions
- TYPE & operator OP (); ✓ Correct answer
- TYPE & operator OP (int);
- TYPE & operator OP (TYPE &);
- TYPE & operator OP (TYPE &, TYPE &);
-
Which of the following function declaration is correct to overload the + operator as member function in Complex class?
Topic: Operator Overloading & Friend Functions
- Complex +(const Complex & rhs);
- operator + Complex (const Complex & rhs);
- Complex operator +(const Complex & rhs); ✓ Correct answer
- Complex operator + ::(const Complex & rhs);
-
Insertion operator is ________________ associative.
Topic: Operator Overloading & Friend Functions
- Left to Left
- Right to Left
- Left to Right ✓ Correct answer
- Right to Right
-
What will be the output of the following code? #include<iostream> using namespace std; int main() { int const x = 10;cout << ++x;}
Topic: Operator Overloading & Friend Functions
- 10 ✓ Correct answer
- Run Time Error
- 11
- Compile time Error
-
In C++, the subscript operator [] must be overloaded as a _______ of the class, with one parameter of _______ type.
Topic: Operator Overloading & Friend Functions
- Member function, int ✓ Correct answer
- Member function, char
- Non-member function, int
- Non-member function, char
-
In C++, which of the following operator can only be overloaded as a member function of the class?
Topic: Operator Overloading & Friend Functions
- Equality Operator: ==
- Function Operator: ()
- Inequality Operator: !=
- Stream Extraction Operator: >> ✓ Correct answer
-
Which of the following operator can be overloaded?
Topic: Operator Overloading & Friend Functions
- +
- ++
- +=
- All of the above ✓ Correct answer
-
__________ operator is used to access via the variable name?
Topic: Operator Overloading & Friend Functions
- dot operator (.) ✓ Correct answer
- arrow operator (->)
- equal operator (=)
- All of the above
-
An operator in C++ can be overloaded using __________ keyword.
Topic: Operator Overloading & Friend Functions
- Switch
- Overload
- Load
- Operator ✓ Correct answer
-
In C++, when a binary overloaded operator '+' is called, ______________ is passed as an argument.
Topic: Operator Overloading & Friend Functions
- Left hand operand ✓ Correct answer
- Dot operator
- Right hand operand
- Pointer
-
In C++, if new operator is used, when is the constructor called?
Topic: Operator Overloading & Friend Functions
- Constructor is called to allocate memory
- After the allocation of memory ✓ Correct answer
- Before the allocation of memory
- Depends on code
-
Suppose c1, c2, and c3 are the objects of the Complex class and we overloaded the + operator. c3 = c1 + c2; In this statement, ____________ object will be passed as argument when + operator is called.
Topic: Operator Overloading & Friend Functions
- c2
- c3
- c1 and c2 ✓ Correct answer
- c1
-
Which of the following is unary operator in C++?
Topic: Operator Overloading & Friend Functions
- ++ ✓ Correct answer
- *
- -
- +
-
What will be the output of following C++ code? int a=5; cout<<a++;
Topic: Operator Overloading & Friend Functions
- 0
- 5 ✓ Correct answer
- a
- 6
-
Which of the following concept is more close to encapsulation?
Topic: Encapsulation, Abstraction & Access Control
- Inheritance
- Information Hiding ✓ Correct answer
- Exception Handling
- Polymorphism
-
In classes which of the following is default access specifier?
Topic: Encapsulation, Abstraction & Access Control
- None of the given option
- Private ✓ Correct answer
- Public
- Protected
-
Which of the following is the default access specifier for members of a class?
Topic: Encapsulation, Abstraction & Access Control
- private ✓ Correct answer
- protected and public
- public
- protected and private
-
Main characteristic of information hiding is:
Topic: Encapsulation, Abstraction & Access Control
- Unlimited access
- Limited access ✓ Correct answer
- Keep the model interesting
- Keep the model simple
-
Which of the following is not an access specifier in C ++?
Topic: Encapsulation, Abstraction & Access Control
- hidden ✓ Correct answer
- Global data member
- Limited access
- Private
-
Which of the following concept deals with the security of data?
Topic: Encapsulation, Abstraction & Access Control
- Data Hiding ✓ Correct answer
- Generalization
- Inheritance
- Polymorphism
-
object hides its information from others this concept is known as
Topic: Encapsulation, Abstraction & Access Control
- hidden
- information hiding ✓ Correct answer
- Limited access
- relevant information
-
abstraction provides information according to
Topic: Encapsulation, Abstraction & Access Control
- relevant information
- Information Hiding
- user perspective ✓ Correct answer
- encapsulation, abstraction
-
which of the following is most suitable advantage of information hiding
Topic: Encapsulation, Abstraction & Access Control
- simplifies the model ✓ Correct answer
- Exception Handling
- relevant information
- Keep the model interesting
-
information hiding can be achieved through-------
Topic: Encapsulation, Abstraction & Access Control
- Unlimited access
- Keep the model simple
- encapsulation, abstraction ✓ Correct answer
- relevant information
-
---- is used for hiding the details of an object from the other parts of a program
Topic: Encapsulation, Abstraction & Access Control
- Information hiding
- 2 , 1
- Public
- encapsulation ✓ Correct answer
-
abstraction includes-------
Topic: Encapsulation, Abstraction & Access Control
- relevant information ✓ Correct answer
- Information hiding
- encapsulation, abstraction
- protected and private
-
abstraction help to
Topic: Encapsulation, Abstraction & Access Control
- reduce the complexity ✓ Correct answer
- Implementation independence
- Keep the model simple
- encapsulation, abstraction
-
Using encapsulation we can achieve
Topic: Encapsulation, Abstraction & Access Control
- Information hiding ✓ Correct answer
- Least interdependencies among modules
- Implementation independence
- All of given options
-
We achieve independence of internal implementation from its external interface through-----------
Topic: Encapsulation, Abstraction & Access Control
- Encapsulation
- Information Hiding
- Abstraction ✓ Correct answer
- both encapsulation and information hiding
-
Keeping in view the principle of abstraction, which of the above information the company needs to save as employee's record?
Topic: Encapsulation, Abstraction & Access Control
- 2 , 1
- 1, 3, 5
- 1, 2, 3 ✓ Correct answer
- All of the above
-
Enclosing all the characteristics of an object within the object itself is described as __________.
Topic: Encapsulation, Abstraction & Access Control
- Information hiding
- All of the above
- Static data member
- Encapsulation ✓ Correct answer
-
The __________ tells the compiler what task the function will be performing.
Topic: Mixed / Other Important MCQs
- Function declaration
- Function calling
- Function definition ✓ Correct answer
- None of the given
-
Which of the following is the correct way of declaring a constant variable named RollNo?
Topic: Mixed / Other Important MCQs
- const RollNo;
- int const rollNo;
- int RollNo const;
- const int RollNo; ✓ Correct answer
-
Student *ptr = new Student("Ali"); is an example of ____________.
Topic: Mixed / Other Important MCQs
- Destructor
- Constructor
- Dynamic memory allocation ✓ Correct answer
- Static memory allocation
-
__________ provide the facility to access the data member.
Topic: Mixed / Other Important MCQs
- accesser function ✓ Correct answer
- private function
- inline function
- None of the given
-
Which one is not keyword in C++?
Topic: Mixed / Other Important MCQs
- operator
- B_op ✓ Correct answer
- const
- None of given
-
In expression c1*c2+c3-c4 which of the following will be executed in first order
Topic: Mixed / Other Important MCQs
- takes iterators as its first two arguments.
- Global Variables
- Polymorphism
- C1*c2 ✓ Correct answer
-
Which of the following statement(s) describe constant member functions?
Topic: Mixed / Other Important MCQs
- Member functions can be made private
- non of the given
- initialize data member
- All of the given option ✓ Correct answer
-
How many interactions are there in the following scenario Imran has the car. he drive the car and car has four wheels and doors
Topic: Mixed / Other Important MCQs
- Data hiding
- composition
- Vehicle
- 3 ✓ Correct answer
-
a child inherits characteristics from its----- --
Topic: Mixed / Other Important MCQs
- Static
- private function
- Local Variables
- parent ✓ Correct answer
-
member initializer list is used to
Topic: Mixed / Other Important MCQs
- Data Hiding
- constant pointer to constant data
- initialize data members ✓ Correct answer
- static member
-
Which of the following is true about accessor functions?
Topic: Mixed / Other Important MCQs
- functions and classes
- Private members can be accessed using friend functions
- all of the given option ✓ Correct answer
- None of given
-
suppose you have following C + + statement int old value=10; int new value=++old value; what will be the value of old value and newValue after executing above statements ?
Topic: Mixed / Other Important MCQs
- The compiler can only generate copy for the int type data
- Two-way Association
- oldValue=11,newValue=11 ✓ Correct answer
- initialize data members
-
which of the following is not true about constant number function
Topic: Mixed / Other Important MCQs
- all of the given option ✓ Correct answer
- None of given
- Constant Variables
- Function declaration
-
Which of the following are an advantage of OOP?
Topic: Mixed / Other Important MCQs
- OOP makes it easy to re-use the code
- It provides an ability to create one user defined data type by extending the other
- It provides the facility of defining Abstract data types through which real world entities can be defined better.
- All of the given options ✓ Correct answer
-
What is true about function templates?
Topic: Mixed / Other Important MCQs
- The compiler generates only one copy of the function template
- The compiler generates a copy of function respective to each type of data ✓ Correct answer
- The compiler can only generate copy for the int type data
- None of the given.
-
Which of the following is the best approach if it is required to have more than one functions having exactly same functionality and implemented on different data types?
Topic: Mixed / Other Important MCQs
- Templates ✓ Correct answer
- Overloading
- Data hiding
- Encapsulation
-
The find() algorithm
Topic: Mixed / Other Important MCQs
- finds matching sequences of elements in two containers.
- finds a container that matches a specified container.
- takes iterators as its first two arguments. ✓ Correct answer
- takes container elements as its first two arguments.
-
Which of the following option is false?
Topic: Mixed / Other Important MCQs
- Public members are accessible from other classes also
- Private members can be accessed using friend functions
- Data members can't be inherited ✓ Correct answer
- Member functions can be made private
-
#include<iostream>
Topic: Mixed / Other Important MCQs
- 1 1 1
- 3 3 3
- 1 2 3 ✓ Correct answer
- 1 1 2
-
Car carries passengers.
Topic: Mixed / Other Important MCQs
- Public Transport
- Passenger Transport
- Vehicle ✓ Correct answer
- Navy Ships
-
What is a class?
Topic: OOP Concepts, Classes & Objects
- A class is a section of computer memory containing objects
- A class is a section of the hard disk reserved for object oriented programs
- A class is the part of an object that contains the variables.
- A class is a description of a kind of object ✓ Correct answer
-
We capture the object attributes and behavior in Object Oriented programming using----- ----------
Topic: OOP Concepts, Classes & Objects
- Class ✓ Correct answer
- Function
- Data Members
- Instances
-
Graphical representation of the classes and objects is called object model it shows - ------
Topic: OOP Concepts, Classes & Objects
- Class Name only
- Class Name and attributes
- Relationships of the objects and classes
- all of the given ✓ Correct answer
-
When is a constructor called?
Topic: OOP Concepts, Classes & Objects
- Each time the constructor identifier is used in a program statement
- During the instantiation of a new object ✓ Correct answer
- During the construction of a new class
- At the beginning of any program execution
-
In c++ by default access of classes is .
Topic: OOP Concepts, Classes & Objects
- Private ✓ Correct answer
- Protected
- Public
- None of the given
-
Encapsulation means Select correct option:
Topic: OOP Concepts, Classes & Objects
- Extending the behavior of class in another class
- Data and behavior are tightly coupled within an entity ✓ Correct answer
- One entity takes all the attributes and operations of the other
- Taking out the common features and put those in a separate class
-
Which of the following is an advantage of OOP?
Topic: OOP Concepts, Classes & Objects
- OOP makes it easy to re-use the code
- It provides an ability to create one user defined data type by extending the other
- It provides the facility of defining Abstract data types through which real world entities can be defined better
- All of the given options ✓ Correct answer
-
Objects having identical characteristics belong to
Topic: OOP Concepts, Classes & Objects
- Same class ✓ Correct answer
- Two different classes
- Any number of different classes
- Objects can not have identical characteristics
-
At the most, how many instances of certain class can be created?
Topic: OOP Concepts, Classes & Objects
- 1
- 6
- 3
- none of these ✓ Correct answer
-
________ is/are used to access information hidden within an object?
Topic: OOP Concepts, Classes & Objects
- Interface ✓ Correct answer
- Private data members
- Private member functions
- Both public and private members
-
A C++ class is similar to --------------------
Topic: OOP Concepts, Classes & Objects
- Structure ✓ Correct answer
- Header File
- Library File
- None of the given
-
Which of the following statements best describes a constructor?
Topic: OOP Concepts, Classes & Objects
- It is used to initialize the data members of a class ✓ Correct answer
- It is used to destroy the objects of a class
- It allocates memory for static members only
- It is called only once in a program
-
A class is a blueprint of ______.
Topic: OOP Concepts, Classes & Objects
- Objects ✓ Correct answer
- Functions
- Data members
- Structures
-
An object has ______ interface(s).
Topic: OOP Concepts, Classes & Objects
- Exactly one
- One or more than one ✓ Correct answer
- Exactly two
- No
-
Suppose Test is a class and void show() is its public member function. Which of the following is the correct call of show() using a Test pointer ptr?
Topic: OOP Concepts, Classes & Objects
- ptr.show()
- ptr->show() ✓ Correct answer
- *ptr.show()
- Test->show()
-
Which of the following features of OOP is used to deal with only relevant details?
Topic: OOP Concepts, Classes & Objects
- Encapsulation
- Abstraction ✓ Correct answer
- Inheritance
- Polymorphism
-
An object has attributes, operations and ______.
Topic: OOP Concepts, Classes & Objects
- Unique identity ✓ Correct answer
- Static members
- Friend functions
- Constructors
-
______ is the set of functions of an object that are exposed to other objects.
Topic: OOP Concepts, Classes & Objects
- Interface ✓ Correct answer
- Class
- Message
- State
-
The return type of a constructor is of -------------
Topic: Constructors, Destructors & Copy Control
- Integer
- Chracter
- Double
- No type ✓ Correct answer
-
Default constructor is such constructor which either has no ---------or if it has some parameters these have -------- values
Topic: Constructors, Destructors & Copy Control
- Parameter, temporary
- Null, Parameter
- Parameter, default ✓ Correct answer
- non of the given
-
A copy constructor is invoked when
Topic: Constructors, Destructors & Copy Control
- a function do not returns by value.
- an argument is passed by value. ✓ Correct answer
- a function returns by reference.
- an argument is passed by reference.
-
By default, assignment operator (=) performs,
Topic: Constructors, Destructors & Copy Control
- Shallow copy ✓ Correct answer
- Deep copy
- Both of these
- None of these
-
Compiler can automatically generate the following constructor/s for a class,
Topic: Constructors, Destructors & Copy Control
- Default constructor
- Copy constructor
- Both of these ✓ Correct answer
- None of these
-
If we have not given any constructor for the class, compiler generates which of the following constructors?
Topic: Constructors, Destructors & Copy Control
- Emplicit Default Constructor
- Implicit Default Constructor ✓ Correct answer
- Emplicit Parameterized Constructor
- Implicit Parameterized Constructor
-
Suppose we have defined derived class copy constructor but have not defined base class copy constructor then compiler will,
Topic: Constructors, Destructors & Copy Control
- Use base class default constructor
- Generate base class copy constructor itself ✓ Correct answer
- Use base class assignment operator
- None of these options is correct
-
Compiler generated copy constructor performs
Topic: Constructors, Destructors & Copy Control
- Shallow copy ✓ Correct answer
- Deep copy
- Both Shallow and Deep copy
- None of these options
-
Suppose both derive and base classes have compilers generated copy constructors then derived class copy construct is
Topic: Constructors, Destructors & Copy Control
- Compiler generated default constructor
- Compiler generated copy constructor ✓ Correct answer
- Both of these
- None of these
-
In case of dynamic memory allocation in or class we should use
Topic: Constructors, Destructors & Copy Control
- Default assignment operator
- User defined assignment operator ✓ Correct answer
- Default copy constructor
- None of these
-
Consider the following two lines of code written for class student Student sobj1; Student sobj2(sobj1) In line 2 which constructor of student class will be called?
Topic: Constructors, Destructors & Copy Control
- Default constructor of student class
- Copy constructor of student class ✓ Correct answer
- Both default and copy constructor of student class
- No constructor will be called
-
C++ compiler does not allow to dynamically allocate memory for objects.
Topic: Constructors, Destructors & Copy Control
- False ✓ Correct answer
- True
-
What problem(s) may occur when we copy objects without using deep copy constructor?
Topic: Constructors, Destructors & Copy Control
- Dangling pointer ✓ Correct answer
- Memory Leakage
- All of the given
- System crash
-
Member initialization list is used to ______.
Topic: Constructors, Destructors & Copy Control
- Declare data members
- Initialize data members ✓ Correct answer
- Define member functions
- Destroy objects
-
Suppose a class does not have any constructor. What will happen when an object of this class is created?
Topic: Constructors, Destructors & Copy Control
- Compiler will generate an error
- Compiler will call the implicit default constructor ✓ Correct answer
- Object will contain only static members
- Destructor will be called automatically
-
A class can have only ______ destructor.
Topic: Constructors, Destructors & Copy Control
- One ✓ Correct answer
- Two
- Three
- Unlimited
-
In C++, which of the following keywords works only with constructors?
Topic: Constructors, Destructors & Copy Control
- explicit ✓ Correct answer
- virtual
- friend
- static
-
In case of multiple inheritance a derived class inherits,
Topic: Access Specifiers & Inheritance
- Only the public member functions of its base classes
- Only the public data members of its base classes
- Both public data members and member functions of all its base classes ✓ Correct answer
- Data members and member functions of any two base classes
-
In Private -------------- only member functions and friend classes or functions of a derived class can convert pointer or reference of derived object to that of parent object
Topic: Access Specifiers & Inheritance
- specialization
- inheritance ✓ Correct answer
- abstraction
- composition
-
Public methods of base class can --------- be accessed in its derived class
Topic: Access Specifiers & Inheritance
- directly ✓ Correct answer
- inderectly
- simultaniously
- non of the given
-
------------- members are somewhere between public and private members. They are used in inheritance
Topic: Access Specifiers & Inheritance
- protected ✓ Correct answer
- public
- private
- global
-
Multiple inheritance can be of type
Topic: Access Specifiers & Inheritance
- Public
- Private
- Protected
- All of the given ✓ Correct answer
-
The default inheritance mode is,
Topic: Access Specifiers & Inheritance
- Public inheritance
- Protected inheritance
- Private inheritance ✓ Correct answer
- None of the given
-
In case of public inheritance, protected members of base class will be in derived class?
Topic: Access Specifiers & Inheritance
- Private
- Public
- Protected ✓ Correct answer
- Hidden
-
In protected inheritance the public members of base class become _ in derived class.
Topic: Access Specifiers & Inheritance
- Public
- Private
- Protected ✓ Correct answer
- None of the given
-
Which of the following is not type of inheritance in c++?
Topic: Access Specifiers & Inheritance
- Public
- Protected
- Restricted ✓ Correct answer
- Private
-
Which of the following type of inheritance is used to model "Implemented in terms of" relationship?
Topic: Access Specifiers & Inheritance
- Public
- Private ✓ Correct answer
- Protected
- Confidential
-
When we want to implement one class in terms of another class then we use,
Topic: Access Specifiers & Inheritance
- Public inheritance
- Protected inheritance
- Private inheritance ✓ Correct answer
- None of these options
-
Public inheritance represents;
Topic: Access Specifiers & Inheritance
- "IS A "relationship ✓ Correct answer
- "Has A" relationship
- "IS Special kind of" relationship
- None of these option
-
Child class can call constructor of its
Topic: Access Specifiers & Inheritance
- Direct base class ✓ Correct answer
- Indirect base class
- Both direct and indirect base classes
- None of these
-
We can have type of member functions in a class.
Topic: Access Specifiers & Inheritance
- Public
- Private
- Protected
- All of these options ✓ Correct answer
-
In specialization we can,
Topic: Access Specifiers & Inheritance
- Replace child class with its base class
- Replace base class with its child class ✓ Correct answer
- Replace both child and base classes interchangeably
- None of the given option
-
In private inheritance derived class pointer can be assigned to base class pointer in,
Topic: Access Specifiers & Inheritance
- Main function
- In derived class member and friend class function ✓ Correct answer
- In base class member and friend functions
- None of the given option
-
In case of private inheritance, private members of base class will be in derived class?
Topic: Access Specifiers & Inheritance
- Private
- Public
- Protected
- Hidden ✓ Correct answer
-
Which of the following access specifier ensure that base class member is accessible in derived class and Not outside of this class
Topic: Access Specifiers & Inheritance
- Public
- Private
- Protected ✓ Correct answer
- All of above
-
A child class can call constructor of the parent class through ______.
Topic: Access Specifiers & Inheritance
- Its constructor initialization list ✓ Correct answer
- Its constructor body
- Both its constructor initialization list and body
- It cannot call the constructor of its parent class
-
Consider the code below class class1{ Private: Void func1(); }; Class class2 : public class1{ }; Function func1 of class 1 is in class2.
Topic: Access Specifiers & Inheritance
- Public
- Protected
- Private
- None of the given options ✓ Correct answer
-
Generalization is a ______ approach.
Topic: Access Specifiers & Inheritance
- Top-down
- Bottom-up ✓ Correct answer
- Side-by-side
- None of the given
-
Which of the following is NOT an access specifier in C++?
Topic: Access Specifiers & Inheritance
- Public
- Private
- Protected
- Hidden ✓ Correct answer
-
In ______, a base class cannot always be replaced by its derived class.
Topic: Access Specifiers & Inheritance
- Generalization
- Specialization ✓ Correct answer
- Inheritance
- Composition
-
Which of the following is an advantage of inheritance?
Topic: Access Specifiers & Inheritance
- Reusability ✓ Correct answer
- Encapsulation
- Data hiding
- Abstraction
-
What is meant by multiple inheritance?
Topic: Access Specifiers & Inheritance
- Deriving a derived class from more than one base class ✓ Correct answer
- Deriving many classes from a single base class
- Creating many objects of one class
- Inheriting only static members
-
If class A inherits from class B, then class ______ contains all the characteristics of class ______.
Topic: Access Specifiers & Inheritance
- A, B ✓ Correct answer
- B, A
- B, B
- A, A
-
Minimum number of classes required for implementing multiple inheritance is ______.
Topic: Access Specifiers & Inheritance
- 1
- 2
- 3 ✓ Correct answer
- 4
-
Associativity can be changed in operator overloading.
Topic: Operator Overloading
- True
- False ✓ Correct answer
-
A normal C++ operator that acts in special ways on newly defined data types is said to be
Topic: Operator Overloading
- glorified.
- encapsulated.
- classified.
- overloaded. ✓ Correct answer
-
Suppose obj1 and obj2 are two objects of a user defined class A. An + operator is overloaded to add obj1 and obj2 using the function call obj1+obj2. Identify the correct function prototype against the given call?
Topic: Operator Overloading
- A operator + ( A &obj); ✓ Correct answer
- int + operator();
- int operator (plus) ();
- A operator(A &obj3);
-
In c++, compiler can generate which of the following operators 'code
Topic: Operator Overloading
- ==
- = ✓ Correct answer
- &
-
Which of the following operators cannot be overloaded?
Topic: Operator Overloading
- Scope resolution operator ( :: ) ✓ Correct answer
- Insertion operator ( << )
- Extraction operator ( >> )
- The relation operator ( > )
-
In operator overloading, which of the following operator takes one or no argument.
Topic: Operator Overloading
- ++ ✓ Correct answer
- *
- %
- <<
-
We can call base class assignment operator in derived class user defined assignment operator
Topic: Operator Overloading
- Implicitly
- Explicitly ✓ Correct answer
- Using both of these options
- Using none of these options
-
Which operator can not be overloaded?
Topic: Operator Overloading
- The relation operator ( >= )
- Assignment operator ( = )
- Script operator ( [] )
- Conditional operator (? : ) ✓ Correct answer
-
To convert from a user-defined class to a basic type, you would most likely use
Topic: Operator Overloading
- a built-in conversion operator.
- a one-argument constructor.
- an overloaded = operator.
- a conversion operator that's a member of the class. ✓ Correct answer
-
Assignment operators are ______ associative.
Topic: Operator Overloading
- Left
- Right ✓ Correct answer
- Both left and right
- Non-associative
-
A post-fix unary operator is implemented in C++ using a member function with ______.
Topic: Operator Overloading
- No argument
- One dummy int argument ✓ Correct answer
- Two arguments
- A reference argument
-
______ defines the order of evaluation of an operator in an expression.
Topic: Operator Overloading
- Operator associativity
- Operator precedence ✓ Correct answer
- Operator overloading
- Operator priority
-
Suppose str1, str2 and str3 are objects of class String. Choose the appropriate declaration of the overloaded assignment operator for the statement str1 = str2 = str3 to work correctly.
Topic: Operator Overloading
- void operator = (const String &);
- String & operator = (const String &); ✓ Correct answer
- String operator = (String);
- int operator = (const String &);
-
class DocElement { public: virtual void Print() { cout << "Generic element"; } }; class Heading : public DocElement { public: void Print() { cout << "Heading element"; } }; class Paragraph : public DocElement { public: void Print() { cout << "Paragraph element"; } }; void main() { DocElement * p = new Paragraph(); p->Print(); } When you run this program, it will print out a single line to the console output. What will be in that line? Select one correct answer from the following list:
Topic: Polymorphism, Virtual Functions & Abstract Classes
- Generic element
- Heading element
- Paragraph element ✓ Correct answer
- Nothing will be printed.
-
When a virtual function is called by referencing a specific object by name and using the dot member selection operator (e.g., squareObject.draw()), the reference is resolved at compile time.
Topic: Polymorphism, Virtual Functions & Abstract Classes
- True ✓ Correct answer
- False
-
Compiler performs ________ type checking to diagnose type errors,
Topic: Polymorphism, Virtual Functions & Abstract Classes
- Static ✓ Correct answer
- Dynamic
- Bound
- Unbound
-
The type that is used to declare a reference or pointer is called its ---------
Topic: Polymorphism, Virtual Functions & Abstract Classes
- default type
- static type ✓ Correct answer
- abstract type
- reference type
-
It is sometimes useful to specify a class from which no objects will ever be created.
Topic: Polymorphism, Virtual Functions & Abstract Classes
- True ✓ Correct answer
- False
-
A pointer to a base class can point to objects of a derived class.
Topic: Polymorphism, Virtual Functions & Abstract Classes
- True ✓ Correct answer
- False
-
A function call is resolved at run-time in___________
Topic: Polymorphism, Virtual Functions & Abstract Classes
- non-virtual member function.
- virtual member function. ✓ Correct answer
- Both non-virtual member and virtual member function.
- None of given
-
The mechanism of selecting function at run time according to the nature of calling object is called,
Topic: Polymorphism, Virtual Functions & Abstract Classes
- late binding ✓ Correct answer
- static binding
- virtual binding
- None of the given options
-
An abstract class is useful when,
Topic: Polymorphism, Virtual Functions & Abstract Classes
- We do not derive any class from it.
- There are multiple paths from one derived class to another.
- We do not want to instantiate its object. ✓ Correct answer
- You want to defer the declaration of the class.
-
Function overriding is done in context of,
Topic: Polymorphism, Virtual Functions & Abstract Classes
- Single class
- Single derived class
- Single base class
- Derived and base classes ✓ Correct answer
-
To make a pure virtual, we need to give _after() of this function.
Topic: Polymorphism, Virtual Functions & Abstract Classes
- =0; ✓ Correct answer
- =1;
- Null;
- None of the given
-
Suppose person is a user defined class. In statement "Person*pPtr", static type of pPtr is ----.
Topic: Polymorphism, Virtual Functions & Abstract Classes
- pPtr
- pointer
- person ✓ Correct answer
- None of the given
-
Which statement is true for concrete class?
Topic: Polymorphism, Virtual Functions & Abstract Classes
- It cannot be inherit from an abstract class
- It can be instantiated ✓ Correct answer
- It cannot be instantiated
- None of given
-
Which of the following causes run time binding?
Topic: Polymorphism, Virtual Functions & Abstract Classes
- Declaring object of abstract class
- Declaring pointer of abstract class ✓ Correct answer
- Declaring overridden methods as non-virtual
- None of the given
-
In ______, a base class can be replace by its derived class,
Topic: Polymorphism, Virtual Functions & Abstract Classes
- Sub-Typing ✓ Correct answer
- Super-Typing
- Multiple-Typing
- Restricted Typing
-
________ Binding means that target function for a call is selected at compile time.
Topic: Polymorphism, Virtual Functions & Abstract Classes
- Static ✓ Correct answer
- Dynamic
- Automatic
- None of the given
-
A pure virtual function is a virtual function that
Topic: Polymorphism, Virtual Functions & Abstract Classes
- causes its class to be abstract. ✓ Correct answer
- returns nothing.
- is used in a derived class.
- takes no arguments.
-
class A { public: virtual void MyVirtualMethod() = 0; }; class B : public A { public: void MyVirtualMethod() { //do something } }; Considering the given code, which of the following statements is correct?
Topic: Polymorphism, Virtual Functions & Abstract Classes
- Class B is a an abstract class
- Class A is a concrete class
- Object of class A can not be instantiated ✓ Correct answer
- Class B is a child class of class A
-
The keyword that is used that the variable can not change state?
Topic: Static, Const & Friend Functions
- static
- const ✓ Correct answer
- friend
- private
-
Friend's functions of class are _ members of that class.
Topic: Static, Const & Friend Functions
- Public
- Private
- Protected
- None of the given ✓ Correct answer
-
A static member function cannot be declared ______.
Topic: Static, Const & Friend Functions
- Static
- Implicit
- Explicit
- Virtual ✓ Correct answer
-
Friend functions are _____________ functions of a class.
Topic: Static, Const & Friend Functions
- None of given
- object member
- non-member ✓ Correct answer
- data member
-
If you do not initialize a static variable of int type, it is automatically initialized with ______.
Topic: Static, Const & Friend Functions
- 1
- 0 ✓ Correct answer
- Garbage value
- Null
-
________ is represented by a line with an unfilled diamond head towards the container.
Topic: Composition, Aggregation & Association
- Inheritance
- Association
- Aggregation ✓ Correct answer
- Composition
-
Aggregation between objects shows that objects have ______ relationship.
Topic: Composition, Aggregation & Association
- Strong
- Weak ✓ Correct answer
- No
- Permanent
-
A book placed in a bookshelf is an example of ______.
Topic: Composition, Aggregation & Association
- Composition
- Aggregation ✓ Correct answer
- Inheritance
- Association
-
Composition is a ______ relationship, whereas aggregation is a ______ relationship.
Topic: Composition, Aggregation & Association
- Weak, strong
- Strong, weak ✓ Correct answer
- Strong, permanent
- Temporary, weak
-
A fan has wings. Which type of relationship exists between fan and wings?
Topic: Composition, Aggregation & Association
- Association
- Aggregation
- Composition ✓ Correct answer
- Inheritance
-
______ associates the objects of exactly two classes.
Topic: Composition, Aggregation & Association
- Binary association ✓ Correct answer
- Unary association
- N-ary association
- Aggregation
-
The sub-object's life is not dependent on the life of the master class in ______.
Topic: Composition, Aggregation & Association
- Composition
- Aggregation ✓ Correct answer
- Association
- Inheritance
-
______ is the weakest link between objects.
Topic: Composition, Aggregation & Association
- Composition
- Aggregation
- Simple association ✓ Correct answer
- Inheritance
-
Composition is a ______ relationship.
Topic: Composition, Aggregation & Association
- Is-a
- Part-whole ✓ Correct answer
- Generalization
- Specialization
-
The main function of scope resolution operator (::) is,
Topic: Object-Oriented Modeling & Miscellaneous
- To define an object
- To define a data member
- To link the definition of an identifier to its declaration ✓ Correct answer
- All of the given
-
Methodologies to the development of reusable software relate to .
Topic: Object-Oriented Modeling & Miscellaneous
- Structure programming
- Procedural programming
- Generic programming ✓ Correct answer
- None of the given
-
A class hierarchy
Topic: Object-Oriented Modeling & Miscellaneous
- Shows the same relationships as a organization chart
- Describe "has a "relationship.
- Describe "is a kind of" relationship. ✓ Correct answer
- Shows the same relationships as a family tree.
-
Which of the following is Not casting operator in c++ standard?
Topic: Object-Oriented Modeling & Miscellaneous
- Static-cast
- Var-cast ✓ Correct answer
- Dynamic-cast
- Reinterpret-cast
-
Which of the following is /are casting operator(s) inc++?
Topic: Object-Oriented Modeling & Miscellaneous
- Static_cast
- Const_cast
- Dynamic_cast
- All of the given options ✓ Correct answer
-
If we extend our model and the rest of the model is not affected, then it is called ______.
Topic: Object-Oriented Modeling & Miscellaneous
- Flexibility ✓ Correct answer
- Coupling
- Encapsulation
- Polymorphism
-
Defining a function inside the class body, the compiler treats that function as:
Topic: Object-Oriented Modeling & Miscellaneous
- Virtual function
- Inline function ✓ Correct answer
- Friend function
- Static function
-
When we define a function outside the class, we must use the keyword ______ to make the function inline.
Topic: Object-Oriented Modeling & Miscellaneous
- virtual
- inline ✓ Correct answer
- static
- friend