0% found this document useful (0 votes)
40 views

Oops Mcqs

The document discusses the basics of object-oriented programming including concepts like classes, objects, inheritance, encapsulation, and polymorphism. It provides examples of code and definitions for key OOP terms and asks multiple choice questions to test understanding.

Uploaded by

Sayan Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Oops Mcqs

The document discusses the basics of object-oriented programming including concepts like classes, objects, inheritance, encapsulation, and polymorphism. It provides examples of code and definitions for key OOP terms and asks multiple choice questions to test understanding.

Uploaded by

Sayan Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 113

OOP

Basics

1. Which was the first purely object oriented programming language developed?
a) Java
b) C++
c) SmallTalk
d) Kotlin
2. Which of the following best defines a class?
a) Parent of an object
b) Instance of an object
c) Blueprint of an object
d) Scope of an object
3. Who invented OOP?
a) Alan Kay
b) Andrea Ferro
c) Dennis Ritchie
d) Adele Goldberg
4. What is the additional feature in classes that was not in structures?
a) Data members
b) Member functions
c) Static data allowed
d) Public access specifier
5. Which is not feature of OOP in general definitions?
a) Code reusability
b) Modularity
c) Duplicate/Redundant data
d) Efficient Code
6. Pure OOP can be implemented without using class in a program. (True or False)
a) True
b) False
7. Which Feature of OOP illustrated the code reusability?
a) Polymorphism
b) Abstraction
c) Encapsulation
d) Inheritance
8. Which language does not support all 4 types of inheritance?
a) C++
b) Java
c) Kotlin
d) Small Talk
9. How many classes can be defined in a single program?
a) Only 1
b) Only 100
c) Only 999
d) As many as you want
10. When OOP concept did first came into picture?
a) 1970’s
b) 1980’s
c) 1993
d) 1995
11. Why Java is Partially OOP language?
a) It supports usual declaration of primitive data types
b) It doesn’t support all types of inheritance
c) It allows code to be written outside classes
d) It does not support pointers
12. Which concept of OOP is false for C++?
a) Code can be written without using classes
b) Code must contain at least one class
c) A class must have member functions
d) At least one object should be declared in code
13. Which header file is required in C++ to use OOP?
a) iostream.h
b) stdio.h
c) stdlib.h
d) OOP can be used without using any header file
14. Which of the two features match each other?
a) Inheritance and Encapsulation
b) Encapsulation and Polymorphism
c) Encapsulation and Abstraction
d) Abstraction and Polymorphism
15. Which feature allows open recursion, among the following?
a) Use of this pointer
b) Use of pointers
c) Use of pass by value
d) Use of parameterized constructor

Class

1. Which of the following is not type of class?


a) Abstract Class
b) Final Class
c) Start Class
d) String Class
2. Class is pass by _______
a) Value
b) Reference
c) Value or Reference, depending on program
d) Copy
3. What is default access specifier for data members or member functions declared within a class
without any specifier, in C++?
a) Private
b) Protected
c) Public
d) Depends on compiler
4. Which is most appropriate comment on following class definition?
class Student
{
int a;
public : float a;
};

a) Error : same variable name can’t be used twice


b) Error : Public must come first
c) Error : data types are different for same variable
d) It is correct
5. Which is known as a generic class?
a) Abstract class
b) Final class
c) Template class
d) Efficient Code
6. Size of a class is _____________
a) Sum of the size of all the variables declared inside the class
b) Sum of the size of all the variables along with inherited variables in the class
c) Size of the largest size of variable
d) Classes doesn’t have any size
7. Which class can have member functions without their implementation?
a) Default class
b) String class
c) Template class
d) Abstract class
8. Which of the following describes a friend class?
a) Friend class can access all the private members of the class, of which it is a friend
b) Friend class can only access protected members of the class, of which it is a friend
c) Friend class don’t have any implementation
d) Friend class can’t access any data member of another class but can use it’s methods
9. What is the scope of a class nested inside another class?
a) Protected scope
b) Private scope
c) Global scope
d) Depends on access specifier and inheritance used
10. Class with main() function can be inherited.
a) True
b) False
11. Which among the following is false, for a member function of a class?
a) All member functions must be defined
b) Member functions can be defined inside or outside the class body
c) Member functions need not be declared inside the class definition
d) Member functions can be made friend to another class using the friend keyword
12. Which syntax for class definition is wrong?
a) class student{ };
b) student class{ };
c) class student{ public: student(int a){ } };
d) class student{ student(int a){} };
13. Which of the following pairs are similar?
a) Class and object
b) Class and structure
c) Structure and object
d) Structure and functions
14. Which among the following is false for class features?
a) Classes may/may not have both data members and member functions
b) Class definition must be ended with a colon
c) Class can have only member functions with no data members
d) Class is similar to union and structures
15. Instance of which type of class can’t be created?
a) Anonymous class
b) Nested class
c) Parent class
d) Abstract class

` objects

1. Which definition best describes an object?


a) Instance of a class
b) Instance of itself
c) Child of a class
d) Overview of a class
2. How many objects can be declared of a specific class in a single program?
a) 32768
b) 127
c) 1
d) As many as you want
3. Which among the following is false?
a) Object must be created before using members of a class
b) Memory for an object is allocated only after its constructor is called
c) Objects can’t be passed by reference
d) Objects size depends on its class data members
4. Which of the following is incorrect?
a) class student{ }s;
b) class student{ }; student s;
c) class student{ }s[];
d) class student{ }; student s[5];
5. The object can’t be __________
a) Passed by reference
b) Passed by value
c) Passed by copy
d) Passed as function
6. What is size of the object of following class (64 bit system)?

class student { int rollno; char name[20]; static int studentno; };

a) 20
b) 22
c) 24
d) 28
7. Functions can’t return objects.
a) True
b) False
8. How members of an object are accessed?
a) Using dot operator/period symbol
b) Using scope resolution operator
c) Using member names directly
d) Using pointer only
9. If a local class is defined in a function, which of the following is true for an object of that class?
a) Object is accessible outside the function
b) Object can be declared inside any other function
c) Object can be used to call other class members
d) Object can be used/accessed/declared locally in that function
10. Which among the following is wrong?
a) class student{ }; student s;
b) abstract class student{ }; student s;
c) abstract class student{ }s[50000000];
d) abstract class student{ }; class toppers: public student{ }; topper t;
11. Object declared in main() function _____________
a) Can be used by any other function
b) Can be used by main() function of any other program
c) Can’t be used by any other function
d) Can be accessed using scope resolution operator
12. When an object is returned___________
a) A temporary object is created to return the value
b) The same object used in function is used to return the value
c) The Object can be returned without creation of temporary object
d) Object are returned implicitly, we can’t say how it happens inside program
13. Which among the following is correct?
a) class student{ }s1,s2; s1.student()=s2.student();
b) class student{ }s1; class topper{ }t1; s1=t1;
c) class student{ }s1,s2; s1=s2;
d) class student{ }s1; class topper{ }t1; s1.student()=s2.topper();
14. Which among following is correct for initializing the class below?

class student{
int marks;
int cgpa;
public: student(int i, int j){
marks=I;
cgpa=j
}
};

a) student s[3]={ s(394, 9); s(394, 9); s(394,9); };


b) student s[2]={ s(394,9), s(222,5) };
c) student s[2]={ s1(392,9), s2(222,5) };
d) student s[2]={ s[392,9], s2[222,5] };
15. Object can’t be used with pointers because they belong to user defined class, and compiler
can’t decide the type of data may be used inside the class.
a) True
b) False

Features

1. Which feature of OOP indicates code reusability?


a) Encapsulation
b) Inheritance
c) Abstraction
d) Polymorphism
2. If a function can perform more than 1 type of tasks, where the function name remains same,
which feature of OOP is used here?
a) Encapsulation
b) Inheritance
c) Polymorphism
d) Abstraction
3. If different properties and functions of a real world entity is grouped or embedded into a single
element, what is it called in OOP language?
a) Inheritance
b) Polymorphism
c) Abstraction
d) Encapsulation
4. Which of the following is not a feature of pure OOP?
a) Classes must be used
b) Inheritance
c) Data may/may not be declared using object
d) Functions Overloading
5. Which among the following doesn’t come under OOP concept?
a) Platform independent
b) Data binding
c) Message passing
d) Data hiding
6. Which feature of OOP is indicated by the following code?

class student{ int marks; };


class topper:public student{ int age; topper(int age){ this.age=age; } };

a) Inheritance
b) Polymorphism
c) Inheritance and polymorphism
d) Encapsulation and Inheritance
7. Which feature may be violated if we don’t use classes in a program?
a) Inheritance can’t be implemented
b) Object must be used is violated
c) Encapsulation only is violated
d) Basically all the features of OOP gets violated
8. How many basic features of OOP are required for a programming language to be purely OOP?
a) 7
b) 6
c) 5
d) 4
9. The feature by which one object can interact with another object is _____________
a) Data transfer
b) Data Binding
c) Message Passing
d) Message reading
10. ___________ underlines the feature of Polymorphism in a class.
a) Nested class
b) Enclosing class
c) Inline function
d) Virtual Function
11. Which feature in OOP is used to allocate additional function to a predefined operator in any
language?
a) Operator Overloading
b) Function Overloading
c) Operator Overriding
d) Function Overriding
12. Which among doesn’t illustrates polymorphism?
a) Function overloading
b) Function overriding
c) Operator overloading
d) Virtual function
13. Exception handling is a feature of OOP.
a) True
b) False
14. Which among the following, for a pure OOP language, is true?
a) The language should follow 3 or more features of OOP
b) The language should follow at least 1 feature of OOP
c) The language must follow only 3 features of OOP
d) The language must follow all the rules of OOP
15. Does OOP provide better security than POP?
a) Always true for any programming language
b) May not be true with respect to all programming languages
c) It depends on type of program
d) It’s vice-versa is true

Polymorphism

1. Which among the following best describes polymorphism?


a) It is the ability for a message/data to be processed in more than one form
b) It is the ability for a message/data to be processed in only 1 form
c) It is the ability for many messages/data to be processed in one way
d) It is the ability for undefined message/data to be processed in at least one way
2. What do you call the languages that support classes but not polymorphism?
a) Class based language
b) Procedure Oriented language
c) Object-based language
d) If classes are supported, polymorphism will always be supported
3. Which among the following is the language which supports classes but not polymorphism?
a) SmallTalk
b) Java
c) C++
d) Ada
4. If same message is passed to objects of several different classes and all of those can respond in
a different way, what is this feature called?
a) Inheritance
b) Overloading
c) Polymorphism
d) Overriding
5. Which class/set of classes can illustrate polymorphism in the following code?

abstract class student


{
public : int marks;
calc_grade();
}
class topper:public student
{
public : calc_grade()
{
return 10;
}
};
class average:public student
{
public : calc_grade()
{
return 20;
}
};
class failed{ int marks; };

a) Only class student can show polymorphism


b) Only class student and topper together can show polymorphism
c) All class student, topper and average together can show polymorphism
d) Class failed should also inherit class student for this code to work for polymorphism
6. Which type of function among the following shows polymorphism?
a) Inline function
b) Virtual function
c) Undefined functions
d) Class member functions
7. In case of using abstract class or function overloading, which function is supposed to be called
first?
a) Local function
b) Function with highest priority in compiler
c) Global function
d) Function with lowest priority because it might have been halted since long time, because of low
priority
8. Which among the following can’t be used for polymorphism?
a) Static member functions
b) Member functions overloading
c) Predefined operator overloading
d) Constructor overloading
9. What is output of the following program?

class student
{
public : int marks;
void disp()
{
cout<<”its base class”
};
class topper:public student
{
public :
void disp()
{
cout<<”Its derived class”;
}
}
void main() { student s; topper t;
s.disp();
t.disp();
}

a) Its base classIts derived class


b) Its base class Its derived class
c) Its derived classIts base class
d) Its derived class Its base class
10. Which among the following can show polymorphism?
a) Overloading ||
b) Overloading +=
c) Overloading <<
d) Overloading &&
11. Find the output of the following program.

class education
{
char name[10];
public : disp()
{
cout<<”Its education system”;
}
class school:public education
{
public: void dsip()
{
cout<<”Its school education system”;
}
};
void main()
{
school s;
s.disp();
}
}

a) Its school education system


b) Its education system
c) Its school education systemIts education system
d) Its education systemIts school education system
12. Polymorphism is possible in C language.
a) True
b) False
13. Which problem may arise if we use abstract class functions for polymorphism?
a) All classes are converted as abstract class
b) Derived class must be of abstract type
c) All the derived classes must implement the undefined functions
d) Derived classes can’t redefine the function
14. Which among the following is not true for polymorphism?
a) It is feature of OOP
b) Ease in readability of program
c) Helps in redefining the same functionality
d) Increases overhead of function definition always
15. If 2 classes derive one base class and redefine a function of base class, also overload some
operators inside class body. Among these two things of function and operator overloading, where
is polymorphism used?
a) Function overloading only
b) Operator overloading only
c) Both of these are using polymorphism
d) Either function overloading or operator overloading because polymorphism can be applied
only once in a program
Encaptulation

1. Which among the following best describes encapsulation?


a) It is a way of combining various data members into a single unit
b) It is a way of combining various member functions into a single unit
c) It is a way of combining various data members and member functions into a single unit which
can operate on any data
d) It is a way of combining various data members and member functions that operate on those
data members into a single unit
2. If data members are private, what can we do to access them from the class object?
a) Create public member functions to access those data members
b) Create private member functions to access those data members
c) Create protected member functions to access those data members
d) Private data members can never be accessed from outside the class
3. While using encapsulation, which among the following is possible?
a) Code modification can be additional overhead
b) Data member’s data type can be changed without changing any other code
c) Data member’s type can’t be changed, or whole code have to be changed
d) Member functions can be used to change the data type of data members
4. Which feature can be implemented using encapsulation?
a) Inheritance
b) Abstraction
c) Polymorphism
d) Overloading
5. Find which of the following uses encapsulation?
a) void main(){ int a; void fun( int a=10; cout<<a); fun(); }
b) class student{ int a; public: int b;};
c) class student{int a; public: void disp(){ cout<<a;} };
d) struct topper{ char name[10]; public : int marks; }
6. Encapsulation helps in writing ___________ classes in java.
a) Mutable
b) Abstract
c) Wrapper
d) Immutable
7. Which among the following should be encapsulated?
a) The data which is prone to change is near future
b) The data prone to change in long terms
c) The data which is intended to be changed
d) The data which belongs to some other class
8. How can Encapsulation be achieved?
a) Using Access Specifiers
b) Using only private members
c) Using inheritance
d) Using Abstraction
9. Which among the following violates the principle of encapsulation almost always?
a) Local variables
b) Global variables
c) Public variables
d) Array variables
10. Which among the following would destroy the encapsulation mechanism if it was allowed in
programming?
a) Using access declaration for private members of base class
b) Using access declaration for public members of base class
c) Using access declaration for local variable of main() function
d) Using access declaration for global variables
11. Which among the following can be a concept against encapsulation rules?
a) Using function pointers
b) Using char* string pointer to be passed to non-member function
c) Using object array
d) Using any kind of pointer/array address in passing to another function
12. Consider the following code and select the correct option.
class student
{
int marks;
public : int* fun()
{
return &marks;
}
};
main()
{
student s;
int *ptr=c.fun();
return 0;
}

a) This code is good to go


b) This code may result in undesirable conditions
c) This code will generate error
d) This code violates encapsulation
13. Consider the code and select the wrong choice.

class hero
{
char name[10];
public : void disp()
{
cout<<name;
}
};

a) This maintains encapsulation


b) This code doesn’t maintain encapsulation
c) This code is vulnerable
d) This code gives error
14. Encapsulation is the way to add functions in a user defined structure.
a) True
b) False
15. Using encapsulation data security is ___________
a) Not ensured
b) Ensured to some extent
c) Purely ensured
d) Very low

Abstraction

1. Which among the following best defines abstraction?


a) Hiding the implementation
b) Showing the important data
c) Hiding the important data
d) Hiding the implementation and showing only the features
2. Hiding the implementation complexity can ____________
a) Make the programming easy
b) Make the programming complex
c) Provide more number of features
d) Provide better features
3. Class is _________ abstraction.
a) Object
b) Logical
c) Real
d) Hypothetical
4. Object is ________ abstraction.
a) Object
b) Logical
c) Real
d) Hypothetical
5. Abstraction gives higher degree of ________
a) Class usage
b) Program complexity
c) Idealized interface
d) Unstable interface
6. Abstraction can apply to ____________
a) Control and data
b) Only data
c) Only control
d) Classes
7. Which among the following can be viewed as combination of abstraction of data and code.
a) Class
b) Object
c) Inheritance
d) Interfaces
8. Abstraction principle includes___________
a) Use abstraction at its minimum
b) Use abstraction to avoid longer codes
c) Use abstraction whenever possible to avoid duplication
d) Use abstraction whenever possible to achieve OOP
9. Higher the level of abstraction, higher are the details.
a) True
b) False
10. Encapsulation and abstraction differ as ____________
a) Binding and Hiding respectively
b) Hiding and Binding respectively
c) Can be used any way
d) Hiding and hiding respectively
11. In terms of stream and files ____________
a) Abstraction is called a stream and device is called a file
b) Abstraction is called a file and device is called a stream
c) Abstraction can be called both file and stream
d) Abstraction can’t be defined in terms of files and stream
12. If two classes combine some private data members and provides public member functions to
access and manipulate those data members. Where is abstraction used?
a) Using private access specifier for data members
b) Using class concept with both data members and member functions
c) Using public member functions to access and manipulate the data members
d) Data is not sufficient to decide what is being used
13. A phone is made up of many components like motherboard, camera, sensors and etc. If the
processor represents all the functioning of phone, display shows the display only, and the phone
is represented as a whole. Which among the following have highest level of abstraction?
a) Motherboard
b) Display
c) Camera
d) Phone
14. Which among the following is not a level of abstraction?
a) Logical level
b) Physical level
c) View level
d) External level
15. Using higher degree of abstraction __________
a) May get unsafe
b) May reduce readability
c) Can be safer
d) Can increase vulnerability

Constructor

1. Which among the following is called first, automatically, whenever an object is created?
a) Class
b) Constructor
c) New
d) Trigger
2. Which among the following is not a necessary condition for constructors?
a) Its name must be same as that of class
b) It must not have any return type
c) It must contain a definition body
d) It can contains arguments
3. Which among the following is correct?
a) class student{ public: int student(){} };
b) class student{ public: void student (){} };
c) class student{ public: student{}{} };
d) class student{ public: student(){} };
4. In which access should a constructor be defined, so that object of the class can be created in
any function?
a) Public
b) Protected
c) Private
d) Any access specifier will work
5. How many types of constructors are available for use in general (with respect to parameters)?
a) 2
b) 3
c) 4
d) 5
6. If a programmer defines a class and defines a default value parameterized constructor inside it.
He has not defined any default constructor. And then he try to create the object without passing
arguments, which among the following will be correct?
a) It will not create the object (as parameterized constructor is used)
b) It will create the object (as the default arguments are passed)
c) It will not create the object (as the default constructor is not defined)
d) It will create the object (as at least some constructor is defined)
7. Default constructor must be defined, if parameterized constructor is defined and the object is
to be created without arguments.
a) True
b) False
8. If class C inherits class B. And B has inherited class A. Then while creating the object of class C,
what will be the sequence of constructors getting called?
a) Constructor of C then B, finally of A
b) Constructor of A then C, finally of B
c) Constructor of C then A, finally B
d) Constructor of A then B, finally C
9. In multiple inheritance, if class C inherits two classes A and B as follows, which class constructor
will be called first?

class A{ };
class B{ };
class C: public A, public B{ };

a) A()
b) B()
c) C()
d) Can’t be determined
10. Which among the following is true for copy constructor?
a) The argument object is passed by reference
b) It can be defined with zero arguments
c) Used when an object is passed by value to a function
d) Used when a function returns an object
11. If the object is passed by value to a copy constructor?
a) Only public members will be accessible to be copied
b) That will work normally
c) Compiler will give out of memory error
d) Data stored in data members won’t be accessible
12. Which object will be created first?

class student
{
int marks;
};
student s1, s2, s3;

a) s1 then s2 then s3
b) s3 then s2 then s1
c) s2 then s3 then s1
d) all are created at same time
13. Which among the following helps to create a temporary instance?
a) Implicit call to a default constructor
b) Explicit call to a copy constructor
c) Implicit call to a parameterized constructor
d) Explicit call to a constructor
14. Which among the following is correct for the class defined below?

class student
{
int marks;
public: student(){}
student(int x)
{
marks=x;
}
};
main()
{
student s1(100);
student s2();
student s3=100;
return 0;
}
a) Object s3, syntax error
b) Only object s1 and s2 will be created
c) Program runs and all objects are created
d) Program will give compile time error
15. For constructor overloading, each constructor must differ in ___________ and __________
a) Number of arguments and type of arguments
b) Number of arguments and return type
c) Return type and type of arguments
d) Return type and definition

1. How many types of constructors are available, in general, in any language?


a) 2
b) 3
c) 4
d) 5
2. Choose the correct option for the following code.

class student
{
int marks;
}
student s1;
student s2=2;

a) Object s1 should be passed with argument


b) Object s2 should not be declared
c) Object s2 will not be created, but program runs
d) Program gives compile time error
3. Which constructor is called while assigning some object with another?
a) Default
b) Parameterized
c) Copy
d) Direct assignment is used
4. It’s necessary to pass object by reference in copy constructor because ____________
a) Constructor is not called in pass by reference
b) Constructor is called in pass by reference only
c) It passes the address of new constructor to be created
d) It passes the address of new object to be created
5. Which specifier applies only to the constructors?
a) Public
b) Protected
c) Implicit
d) Explicit
6. Which among the following is true?
a) Default constructor can’t be defined by the programmer
b) Default parameters constructor isn’t equivalent to the default constructor
c) Default constructor can be called explicitly
d) Default constructor is and always called implicitly only
7. Which type of constructor can’t have a return type?
a) Default
b) Parameterized
c) Copy
d) Constructors don’t have a return type
8. Why do we use static constructors?
a) To initialize the static members of class
b) To initialize all the members with static value
c) To delete the static members when not required
d) To clear all the static members initialized values
9. When and how many times a static constructor is called?
a) Created at time of object destruction
b) Called at first time when an object is created and only one time
c) Called at first time when an object is created and called with every new object creation
d) Called whenever an object go out of scope
10. Which among the following is true for static constructor?
a) Static constructors are called with every new object
b) Static constructors are used initialize data members to zero always
c) Static constructors can’t be parameterized constructors
d) Static constructors can be used to initialize the non-static members also
11. Within a class, only one static constructor can be created.
a) True
b) False
12. Default constructor initializes all data members as ___________
a) All numeric member with some garbage values and string to random string
b) All numeric member with some garbage values and string to null
c) All numeric member with zero and strings to random value
d) All numeric member with zero and strings to null
13. When is the static constructor called?
a) After the first instance is created
b) Before default constructor call of first instance
c) Before first instance is created
d) At time of creation of first instance
14. If constructors of a class are defined in private access, then __________
a) The class can’t be inherited
b) The class can be inherited
c) Instance can be created only in another class
d) Instance can be created anywhere in the program
15. Which among the following is correct, based on the given code below?

class student
{
int marks;
public : student()
{
cout<<”New student details can be added now”;
}
};
student s1;

a) Cout can’t be used inside the constructor


b) Constructor must contain only initializations
c) This program works fine
d) This program produces errors
1. Copy constructor is a constructor which ________________
a) Creates an object by copying values from any other object of same class
b) Creates an object by copying values from first object created for that class
c) Creates an object by copying values from another object of another class
d) Creates an object by initializing it with another previously created object of same class
2. The copy constructor can be used to ____________
a) Initialize one object from another object of same type
b) Initialize one object from another object of different type
c) Initialize more than one object from another object of same type at a time
d) Initialize all the objects of a class to another object of another class
3. If two classes have exactly same data members and member function and only they differ by
class name. Can copy constructor be used to initialize one class object with another class object?
a) Yes, possible
b) Yes, because the members are same
c) No, not possible
d) No, but possible if constructor is also same
4. The copy constructors can be used to ________
a) Copy an object so that it can be passed to a class
b) Copy an object so that it can be passed to a function
c) Copy an object so that it can be passed to another primitive type variable
d) Copy an object for type casting
5. Which returning an object, we can use ____________
a) Default constructor
b) Zero argument constructor
c) Parameterized constructor
d) Copy constructor
6. If programmer doesn’t define any copy constructor then _____________
a) Compiler provides an implicit copy constructor
b) Compiler gives an error
c) The objects can’t be assigned with another objects
d) The program gives run time error if copying is used
7. If a class implements some dynamic memory allocations and pointers then _____________
a) Copy constructor must be defined
b) Copy constructor must not be defined
c) Copy constructor can’t be defined
d) Copy constructor will not be used
8. What is the syntax of copy constructor?
a) classname (classname &obj){ /*constructor definition*/ }
b) classname (cont classname obj){ /*constructor definition*/ }
c) classname (cont classname &obj){ /*constructor definition*/ }
d) classname (cont &obj){ /*constructor definition*/ }
9. Object being passed to a copy constructor ___________
a) Must be passed by reference
b) Must be passed by value
c) Must be passed with integer type
d) Must not be mentioned in parameter list
10. Out of memory error is given when the object _____________ to the copy constructor.
a) Is passed with & symbol
b) Is passed by reference
c) Is passed as <classname &obj>
d) Is not passed by reference
11. Copy constructor will be called whenever the compiler __________
a) Generates implicit code
b) Generates member function calls
c) Generates temporary object
d) Generates object operations
12. The deep copy is possible only with the help of __________
a) Implicit copy constructor
b) User defined copy constructor
c) Parameterized constructor
d) Default constructor
13. Can a copy constructor be made private?
a) Yes, always
b) Yes, if no other constructor is defined
c) No, never
d) No, private members can’t be accessed
14. The arguments to a copy constructor _____________
a) Must be const
b) Must not be cosnt
c) Must be integer type
d) Must be static
15. Copy constructors are overloaded constructors.
a) True
b) False

1. Which among the following best describes constructor overloading?


a) Defining one constructor in each class of a program
b) Defining more than one constructor in single class
c) Defining more than one constructor in single class with different signature
d) Defining destructor with each constructor
2. Can constructors be overloaded in derived class?
a) Yes, always
b) Yes, if derived class has no constructor
c) No, programmer can’t do it
d) No, never
3. Does constructor overloading include different return types for constructors to be overloaded?
a) Yes, if return types are different, signature becomes different
b) Yes, because return types can differentiate two functions
c) No, return type can’t differentiate two functions
d) No, constructors doesn’t have any return type
4. Which among the following is possible way to overload constructor?
a) Define default constructor, 1 parameter constructor and 2 parameter constructor
b) Define default constructor, zero argument constructor and 1 parameter constructor
c) Define default constructor, and 2 other parameterized constructors with same signature
d) Define 2 default constructors
5. Which constructor will be called from the object created in the code below?
Take Object Oriented Programming Mock Tests - Chapterwise!
Start the Test Now: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
class A
{
int i;
A()
{
i=0; cout&lt;&lt;i;
}
A(int x=0)
{
i=x; cout&lt;&lt;I;
}
};
A obj1;

a) Default constructor
b) Parameterized constructor
c) Compile time error
d) Run time error
6. Which among the following is false for a constructor?
a) Constructors doesn’t have a return value
b) Constructors are always user defined
c) Constructors are overloaded with different signature
d) Constructors may or may not have any arguments being accepted
7. When is the constructor called for an object?
a) As soon as overloading is required
b) As soon as class is derived
c) As soon as class is created
d) As soon as object is created
8. Which among the following function can be used to call default constructor implicitly in java?
a) this()
b) that()
c) super()
d) sub()
9. Why do we use constructor overloading?
a) To use different types of constructors
b) Because it’s a feature provided
c) To initialize the object in different ways
d) To differentiate one constructor from another
10. If programmer have defined parameterized constructor only, then __________________
a) Default constructor will not be created by the compiler implicitly
b) Default constructor will be created by the compiler implicitly
c) Default constructor will not be created but called at runtime
d) Compile time error
11. Which among the following is not valid in java?
a) Constructor overloading
b) Recursive constructor call
c) Default value constructors
d) String argument constructor
12. Which constructor will be called from the object obj2 in the following program?
class A
{
int i;
A()
{
i=0;
}
A(int x)
{
i=x+1;
}
A(int y, int x)
{
i=x+y;
}
};
A obj1(10);
A obj2(10,20);
A obj3;

a) A(int x)
b) A(int y)
c) A(int y, int x)
d) A(int y; int x)
13. What are we only create an object but don’t call any constructor for it in java?
a) Implicit constructor will be called
b) Object is initialized to some null values
c) Object is not created
d) Object is created but points to null
14. Which among the following is false?
a) Constructor can’t be overloaded in Kotlin
b) Constructors can’t be called recursively in java
c) Constructors can be overloaded in C++
d) Constructors overloading depends on different signatures
15. Which is correct syntax?
a) classname objectname= new() integer;
b) classname objectname= new classname;
c) classname objectname= new classname();
d) classname objectname= new() classname();

1. Which among the following best describes the constructors?


a) A function which is called whenever an object is referenced
b) A function which is called whenever an object is created to initialize the members
c) A function which is called whenever an object is assigned to copy the values
d) A function which is called whenever an object is to be given values for members
2. Which among the following best describes destructor?
a) A function which is called just before the objects are destroyed
b) A function which is called after each reference to the object
c) A function which is called after termination of the program
d) A function which is called before calling any member function
3. Which among the following represents correct constructor?
a) ()classname
b) ~classname()
c) –classname()
d) classname()
4. Which among the following is correct syntax for the destructors?
a) classname()
b) ()classname
c) ~classname()
d) -classname()
5. Which among the following is true?
a) First the constructor of parent classes are called in sequence of inheritance
b) First the constructor of child classes are called in the sequence of inheritance
c) First constructor called is of the object being created
d) Constructors are called randomly
6. What is the sequence of destructors call?
a) Same order as that of the constructors call
b) Random order
c) According to the priority
d) Revere of the order of constructor call
7. The destructors _____________________
a) Can have maximum one argument
b) Can’t have any argument
c) Can have more than one argument
d) Can’t have more than 3 arguments
8. Destructor calls ________________ (C++)
a) Are only implicit
b) Are only explicit
c) Can be implicit or explicit
d) Are made at end of program only
9. Number of destructors called are ____________
a) Always equal to number of constructors called
b) Always less than the number of constructors called
c) Always greater than the number of constructors called
d) Always less than or equal to number of constructors
10. For explicit call _________________
a) The destructor must be private
b) The destructor must be public
c) The destructor must be protected
d) The destructor must be defined outside the class
11. If a class have 4 constructors then it must have 4 destructors also.
a) True
b) False
12. Which among the following is true for destructors?
a) Destructors can be overloaded
b) Destructors can be define more than one time
c) Destructors can’t be overloaded
d) Destructors are overloaded in derived classes
13. The constructor _____________
a) Have a return type
b) May have a return type
c) Of derived classes have return type
d) Doesn’t have a return type
14. The destructors ____________
a) Have a return type
b) May have a return type
c) Of derived classes have return type
d) Doesn’t have a return type
15. The destructor can be called before the constructor if required.
a) True
b) False

1. Which among the following describes a destructor?


a) A special function that is called to free the resources, acquired by the object
b) A special function that is called to delete the class
c) A special function that is called anytime to delete an object
d) A special function that is called to delete all the objects of a class
2. When a destructor is called?
a) After the end of object life
b) Anytime in between object’s lifespan
c) At end of whole program
d) Just before the end of object life
3. Which among the following is correct for abstract class destructors?
a) It doesn’t have destructors
b) It has destructors
c) It may or may not have destructors
d) It contains an implicit destructor
4. If in multiple inheritance, class C inherits class B, and Class B inherits class A. In which sequence
are their destructors called if an object of class C was declared?
a) ~C() then ~B() then ~A()
b) ~B() then ~C() then ~A()
c) ~A() then ~B() then ~C()
d) ~C() then ~A() then ~B()
5. Choose the correct sequence of destructors being called for the following code.

class A{ };
class B{ };
class C: public A, public B{ };

a) ~A(), ~B(), ~C()


b) ~B(), ~C(), ~A()
c) ~A(), ~C(), ~B()
d) ~C(), ~B(), ~A()
6. When is the destructor of a global object called?
a) Just before end of program
b) Just after end of program
c) With the end of program
d) Anytime when object is not needed
7. How the constructors and destructors can be differentiated?
a) Destructor have a return type but constructor doesn’t
b) Destructors can’t be defined by the programmer, but constructors can be defined
c) Destructors are preceded with a tilde (~) symbol, and constructor doesn’t
d) Destructors are same as constructors in syntax
8. Destructors doesn’t accept parameters.
a) True
b) False
9. Destructors can be ________
a) Abstract type
b) Virtual
c) Void
d) Any type depending on situation
10. Global destructors execute in ___________ order after main function is terminated.
a) Sequential
b) Random
c) Reverse
d) Depending on priority
11. When is it advised to have user defined destructor?
a) When class contains some pointer to memory allocated in class
b) When a class contains static variables
c) When a class contains static functions
d) When a class is inheriting another class only
12. Which among the following is correct for the destructors concept?
a) Destructors can be overloaded
b) Destructors can have only one parameter at maximum
c) Destructors are always called after object goes out of scope
d) There can be only one destructor in a class
13. Which class destructor will be called first, when following code go out of scope?
class A{ };
class B{ };
class C: public B{ };
A a;
B b;
C c;

a) ~A()
b) ~B()
c) ~C()
d) ~B() and ~C()
14. When an object is passed to a function, its copy is made in the function and then
______________
a) The destructor of the copy is called when function is returned
b) The destructor is never called in this case
c) The destructor is called but it is always implicit
d) The destructor must be user defined
15. What happens when an object is passed by reference?
a) Destructor is not called
b) Destructor is called at end of function
c) Destructor is called when function is out of scope
d) Destructor is called when called explicitly

Access specifier
1. How many types of access specifiers are provided in OOP (C++)?
a) 1
b) 2
c) 3
d) 4
2. Which among the following can be used together in a single class?
a) Only private
b) Private and Protected together
c) Private and Public together
d) All three together

3. Which among the following can restrict class members to get inherited?
a) Private
b) Protected
c) Public
d) All three
4. Which access specifier is used when no access specifier is used with a member of class (java)?
a) Private
b) Default
c) Protected
d) Public
5. Which specifier allows a programmer to make the private members which can be inherited?
a) Private
b) Default
c) Protected
d) Protected and default
6. Which among the following is false?
a) Private members can be accessed using friend functions
b) Member functions can be made private
c) Default members can’t be inherited
d) Public members are accessible from other classes also
7. If a class has all the private members, which specifier will be used for its implicit constructor?
a) Private
b) Public
c) Protected
d) Default
8. If class A has add() function with protected access, and few other members in public. Then class
B inherits class A privately. Will the user will not be able to call _________ from the object of class B.
a) Any function of class A
b) The add() function of class A
c) Any member of class A
d) Private, protected and public members of class A
9. Which access specifier should be used in a class where the instances can’t be created?
a) Private default constructor
b) All private constructors
c) Only default constructor to be public
d) Only default constructor to be protected
10. On which specifier’s data, does the size of a class’s object depend?
a) All the data members are added
b) Only private members are added
c) Only public members are added
d) Only default data members are added
11. If class B inherits class A privately. And class B has a friend function. Will the friend function be
able to access the private member of class A?
a) Yes, because friend function can access all the members
b) Yes, because friend function is of class B
c) No, because friend function can only access private members of friend class
d) No, because friend function can access private member of class A also
12. If an abstract class has all the private members, then _________
a) No class will be able to implement members of abstract class
b) Only single inheritance class can implement its members
c) Only other enclosing classes will be able to implement those members
d) No class will be able to access those members but can implement.
13. Which access specifier should be used so that all the parent class members can be inherited
and accessed from outside the class?
a) Private
b) Default or public
c) Protected or private
d) Public
14. Which access specifier is usually used for data members of a class?
a) Private
b) Default
c) Protected
d) Public
15. Which specifier should be used for member functions of a class?
a) Private
b) Default
c) Protected
d) Public

1. If a function has to be called only by using other member functions of the class, what should be
the access specifier used for that function?
a) Private
b) Protected
c) Public
d) Default
2. Which among the following is correct for the code given below?

class student
{
private: student()
{
}
public : student( int x)
{
marks =x;
}
};

a) The object can never be created


b) The object can be created without parameters
c) Only the object with only 1 parameter can be created
d) Only the object with some parameters can be created
3. Which among the following is true for the code given below?

Become Top Ranker in Object Oriented Programming Now!


class A
{
private : int marks; char name[20];
public :
A(int x=100)
{
marks=x;
}
};

a) Objects can be created with one parameter or without parameter


b) Object can be created only with one parameter
c) Object can be created with more than one parameter
d) Objects can be create only without parameter
4. Which among the following is correct to call a private member from outside the class?
a) object.memberfunction( parameters );
b) object->memberfunction( parameters );
c) object->memberfunction( parameteres); or object.memberfunction( parameters );
d) Not possible
5. If private members have to be accessed directly from outside the class but the access specifier
must not be changed, what should be done?
a) Specifier must be changed
b) Friend function should be used
c) Other public members should be used
d) It is not possible
6. Which access specifier is/are most secure during inheritance?
a) Private
b) Default
c) Protected
d) Private and default
7. Choose the correct option for the code given below.
class A{ static int c=0; public: A(){ c++; } };
a) Constructor will make c=1 for each object created
b) Constructor will make c=0 for each object created
c) Constructor will keep number of objects created
d) Constructor will just initialize c=0 then increment by 1
8. Which option is false for the following code?

class A
{
private : int sum(int x, int y)
{
return x+y;
}
public: A()
{
}
A(int x, int y)
{
cout&lt;&lt;sum(x,y);
}
};

a) Constructor can be created with zero argument


b) Constructor prints sum, if two parameters are passed with object creation
c) Constructor will give error if float values are passed
d) Constructor will take 0 as default value of parameters if not passed
9. Which member will never be used from the following class?

class A()
{
int marks; char name[20];
public : A()
{
marks=100;
}
void disp()
{
cout&lt;&lt;”Marks= ”&lt'&lt;marks;
cout&lt;&lt;”Student”;
}
};

a) name variable will never be used


b) marks variable will never be used
c) constructor will never be used
d) disp() function will never be used
10. Private member functions can be overloaded.
a) True
b) False
11. Which among the following is true?
a) Private member functions can’t be overloaded
b) Private member functions can be overridden
c) Private member functions can’t be overloaded with a public member
d) Private member function can’t be overridden
12. Which data member in following code will be used whenever an object is created?

Class A
{
int x; int y; int z;
public : A()
{
y=100; x=100*y;
}
};

a) x will be used
b) y will be used
c) z will be used
d) All will be used
13. Which member can be considered most secure in the code below?

class A()
{
int a;
private : int b;
protected : int c;
public : int d;
};

a) a
b) b
c) c
d) d
14. Which among the following is correct for the code given below?

class A
{
private : A()
{
}
public : A(int x)
{
}
};
A a;
A b(100);

a) Program will give compile time error


b) Program will run fine
c) Program will give runtime error
d) Program will give logical error
15. Which among the following is correct?
a) Private specifier must be used before public specifier
b) Private specifier must be used before protected specifier
c) Private specifier must be used first
d) Private specifier can be used anywhere in class

1. Which among the following best describes the protected specifier?


a) Members are most secure and can’t be used outside class
b) Members are secure but can be used outside the class
c) Members are secure as private, but can be inherited
d) Members are secure like private, but can’t be inherited
2. If a constructor is defined in protected access, then?
a) It’s instance can be created inside the subclasses
b) It’s instance can be created anywhere in the program
c) It’s instance can be created inside the subclasses and main() function
d) It’s instance can be created inside the parent class only
3. For the following code, choose the correct option.

class A
{
int marks;
protected : A()
{
marks=100;
}
public : A( int x)
{
marks=x;
}
};
a) The instances can be created only in subclasses
b) The instances can be created only in main() function
c) The instances can be created only in parent class
d) The instances can be created anywhere in the program
4. If the protected members are to be made accessible only to the nearest subclass and no
further subclasses, which access specifier should be used in inheritance?
a) The sub class should inherit the parent class privately
b) The sub class should inherit the parent class as protected
c) The sub class should inherit the parent class as public
d) The sub class can use any access modifier
5. What will be the output of the following code (all header files and required things are
included)?

class A
{
int marks;
protected : A(int x)
{
marks=x;
}
public : A()
{
marks=100;
}
}
class B
{
A a;
A b=100;
};
main()
{
A a, b=100;
B c;
}

a) Program runs fine


b) Program gives runtime error
c) Program gives compile time error
d) Program gives logical error
6. Which among the following is true for the given code below?

class A
{
protected : int marks;
public :
A()
{
marks=100;
}
disp()
{
cout&lt;&lt;”marks=”&lt;&lt;marks;
}
};
class B: protected A
{
};
B b;
b.disp();
a) Object b can’t access disp() function
b) Object b can access disp() function inside its body
c) Object b can’t access members of class A
d) Program runs fine
7. Protected members differ from default members as _______
a) Protected members can be accessed outside package using inheritance, but default can’t
b) Default members can be accessed outside package using inheritance, but protected can’t
c) Protected members are allowed for inheritance but Default members are not allowed
d) Both are same
8. If all the members are defined in protected specifier then? (Constructors not considered)
a) Instance of class can’t be created
b) Instance of class can be created anywhere
c) Instance of class can be created only in subclasses
d) Instance of class can be created only in main() function
9. Which among the following is correct for the code given?

class A
{
private: int marks;
A()
{
}
Public : disp()
{
cout&lt;&lt; marks;
}
};
class B: public A
{
}
B b;

a) Instance of B will not be created


b) Instance of B will be created
c) Program gives compile time error
d) Program gives runtime error
10. If protected inheritance is used then _____
a) Public members become public in subclass
b) Protected members become public in subclass
c) Protected members become protected in subclass
d) Protected and Public members become protected in subclass
11. If protected members are to be accessed from outside the class then__________
a) Members must be inherited publicly in subclass
b) Members must accessed using class pointers
c) Members must be accessed as usual
d) Members must be made public
12. Which among the following can use protected access specifier?
a) Members which may be used in other packages
b) Members which have to be secure and should be used by other packages/subclass
c) Members which have to be accessed from anywhere in the program
d) Members which have to be as secure as private but can be used by main() function
13. Protected access is same as default access that is given implicitly in java if no specifier is
mentioned.
a) True
b) False
14. If a class have default constructor defined in private access, and one parameter constructor in
protected mode, how will it be possible to create instance of object?
a) Define a constructor in public access with different signature
b) Directly create the object in the subclass
c) Directly create the object in main() function
d) Not possible
15. What will be the output of the program given below?

class A
{
Public : A(int a=0)
{
cout&lt;&lt;”new A”;
}
};
A a;
A b;
A c;

a) new A new A new A


b) newAnewAnewA
c) new Anew Anew A
d) new A new Anew A

public

1. Which among the following is true for the code given below?

class A
{
int marks;
public : disp()
{
cout&lt;&lt;marks;
}
}
class B: protected A
{
char name[20];
}
A a; a.disp();
B b; b.disp();

a) Only object of class A can access disp() function


b) Only object of class B can access disp() function
c) Both instances can access disp() function
d) Accessing disp() outside class is not possible
2. If the members have to be accessed from anywhere in the program and other packages also,
which access specifier should be used?
a) Public
b) Private
c) Protected
d) Default
3. Which among the following have least security according to the access permissions allowed?
a) Private
b) Default
c) Protected
d) Public
4. Which among the following can be used for outermost class access specifier in java?
a) Private
b) Public
c) Default
d) Default or Public
5. We can reduce the visibility of inherited methods.
a) True
b) False
6. If members of a super class are public, then________
a) All those will be available in subclasses
b) None of those will be available in subclasses
c) Only data members will be available in subclass
d) Only member functions will be available in subclass
7. How many public class(s) (outermost) can be there in a java program?
a) 1
b) 2
c) 3
d) As required
8. What is the output of the following code?

package pack1;
class A
{
public A()
{
System.out.print(“object created”);
}
}
package pack2;
import pack1.*;
class B
{
A a=new A();
}

a) Output is: object created


b) Output is: object createdobject created
c) Compile time error
d) Run time error
9. Which among the following for public specifier is false?
a) The static members can’t be public
b) The public members are available in other packages too
c) The subclasses can inherit the public members privately
d) There can be only one public class in java program
10. A class has its default constructor defined as public. Class B inherits class A privately. The class
___________
a) B will not be able to have instances
b) Only A can have instances
c) Only B can have instances
d) Both classes can have instances
11. Which specifier can be used to inherit protected members as protected in subclass but public
as public in subclass?
a) Private
b) Default
c) Public
d) Protected
12. Which among the following is true for public class?
a) There can be more than one public class in a single program
b) Public class members can be used without using instance of class
c) Public class is available only within the package
d) Public classes can be accessed from any other class using instance
13. If a class doesn’t have public members, then________
a) None of its members will be able to get inherited
b) None of its instance creation will be allowed
c) None of its member function can be called outside the class
d) None of its data members will be able to get initial value
14. In multi-level inheritance(all public), the public members of parent/superclass will ________
a) Will continue to get inherited subsequently
b) Will not be inherited after one subclass inheritance
c) Will not be available to be called outside class
d) Will not be able to allocated with any memory space
15. Which specifier allows to secure the public members of base class in inherited classes?
a) Private
b) Protected
c) Public
d) Private and Protected

Data member

1. What is the term used to indicate the variable and constants of a class?
a) Data members
b) Variables of class
c) Data characters
d) Constants
2. Data members ________________ (C++)
a) Can be initialized with declaration in classes
b) Can be initialized only with help of constructors
c) Can be initialized either in declaration or by constructor
d) Can’t be initialized
3. Which among the following is true for data members?
a) Private data members can be initialized with declaration in class
b) Static members are initialized in constructors
c) Protected data members can be initialized in class directly
d) Static data members are defined outside class, not in constructor
4. What should be done for data member to be of user defined structure type?
a) The structure must have been defined before class.
b) The structure must have been defined after the class definition
c) The structure must be predefined
d) The structure type data members can’t be used
5. How many data members can a class contain?
a) 27
b) 255
c) 1024
d) As many as required
6. How to access data members of a class?
a) Dot operator
b) Arrow operator
c) Dot or arrow as required
d) Dot, arrow or direct call
7. To create a pointer to a private data member of a class, outside the class, which among the
following is correct?
a) Return the address of the private data member using a member function
b) Access the private member using a pointer outside class
c) Declare the member as pointer inside the class
d) Not possible to create pointer to a private member
8. Which among the following is true for use of setter() and getter() function?
a) Considered best for manipulating data values
b) Considered the only proper way to manipulate the values
c) Considered specially for private members manipulation
d) Considered a red flag, and not recommended for large scale use
9. What is the output of following code?

int n=10; // global


class A()
{
private : int n;
public : int m;
A()
{
n=100; m=50;
}
void disp()
{
cout<<”n”<<m<<n;
};

a) 1050100
b) 1005010
c) n5010
d) n50100
10. The static member functions can only use ________
a) Static data members
b) Private data members
c) Protected data members
d) Constant data members
11. A class can have self-referential data members.
a) True
b) False
12. What is the keyword used to make data members have same value?
a) static
b) const
c) double
d) abstract
13. Which data members can be inherited but are private to a class?
a) Private
b) Protected
c) Protected and Static
d) Privately inherited
14. The arguments passed to member functions by reference are considered as data members of
class.
a) True
b) False
15. Which among the following is not allowed for data member declaration?
a) int a;
b) static int a;
c) abstract a;
d) Boolean a;

Member function

1. Which among the following best describes member functions?


a) Functions which are defined within the class
b) Functions belonging a class
c) Functions in public access of a class
d) Functions which are private to class
2. How many types of member functions are generally there in C++?
a) 2
b) 3
c) 4
d) 5
3. How can a static member function be called in the main function?
a) Using dot operator
b) Using arrow operator
c) Using dot or arrow operator
d) Using dot, arrow or using scope resolution operator with class name
4. What are inline member functions?
a) Member functions which can be called without object
b) Member functions whose definition is expanded in place of its call
c) Member functions whose definition is faster than simple function
d) Member function which is defined in single line
5. What happens if non static members are used in static member function?
a) Compile time error
b) Runtime error
c) Executes fine
d) Executes if that member function is not used
6. Static member functions _____________
a) Contains “this” pointer for data members
b) Contains “this” pointer if used for member functions
c) Doesn’t contain “this” pointer
d) Doesn’t contain “this” pointer if member functions are referred
7. How to access members of the class inside a member function?
a) Using this pointer only
b) Using dot operator
c) Using arrow operator
d) Used directly or with this pointer
8. For overloading “( )”, “[ ]” or “->” operators, a class __________
a) Must use static member functions
b) Must use non-static member functions
c) Must be non-static member and should not be friend of class
d) Must use static member function or a friend member function
9. If a virtual member function is defined ___________
a) It should not contain any body and defined by subclasses
b) It must contain body and overridden by subclasses
c) It must contain body and be overloaded
d) It must not contain any body and should not be derived
10. Member functions of a generic class are _____________
a) Not generic
b) Automatically generic
c) To be made generic explicitly
d) Given default type as double
11. Member function of a class can ____________
a) Access all the members of the class
b) Access only Public members of the class
c) Access only the private members of the class
d) Access subclass members
12. Which among the following is proper syntax for class given below?

class A
{
int a,b;
public : void disp();
}

a) void disp::A(){ }
b) void A::disp(){ }
c) void A:disp() { cout<<a<<b ; }
d) void disp:A(){ cout<<a<<b; }
13. A member function can _______________ of the same class.
a) Call other member functions
b) Call only private member functions
c) Call only static member functions
d) Call only const member functions
14. Which member function doesn’t require any return type?
a) Static
b) Constructor
c) Const
d) Constructor and destructor
15. Which among the following is not possible for member function?
a) Access protected members of parent class
b) Definition without return type
c) Access public members of subclass
d) Access static members of class

Local class

1. What are local classes?


a) Classes declared inside a package
b) Classes declared inside a function
c) Classes declared inside a class
d) Classes declared inside structure
2. All member functions of a local class must be ___________
a) Defined outside class body
b) Defined outside the function definition
c) Defined inside the class body
d) Defined at starting of program
3. Can local class members access/use the general local variables (except static, abstract etc.) of
the function in which it is defined?
a) Yes, it can access with arrow operator
b) No, it can’t access with dot operator
c) Yes, it can access using dot operator
d) No, it can’t access In anyway
4. Which type of data can a local class access from the function in which it is defined?
a) Static and extern
b) Abstract and static
c) Void and extern
d) Const and static
5. Local classes can access the type names and enumerators defined by the enclosing function.
a) True
b) False
6. Can static variables be declared inside a local class?
a) Yes, with public access specifier
b) Yes, anywhere as required
c) No, not possible in private access specifier
d) No, not possible anyway
7. All the member functions of local classes are __________ by default.
a) Static
b) Inline
c) Abstract
d) Virtual
8. The enclosing function has no special access to the members of the local class.
a) True
b) False
9. Which language can use inheritance with local classes?
a) Kotlin
b) Java
c) SmallTalk
d) SAP ABAP
10. How many local classes can be defined inside a single function?
a) Only 1
b) Only 3
c) Only 5
d) As many as required
11. All the data members of local class must be ___________
a) Defined with declaration
b) Defined in constructor
c) Declared and defined in constructor
d) Declared using a member function
12. Can two different functions have local class with same name?
a) Yes, since local
b) No, names must be different
c) No, scope doesn’t work here
d) No, ambiguity arises
13. What is the scope of local class?
a) Within the class only
b) Within the function
c) Within the program
d) One time creation and live till end of program
14. Can a function, other than the enclosing function of local class, access the class members?
a) Yes, using object
b) Yes, using direct call
c) Yes, using pointer
d) No, can’t access
15. Which among the following is the main advantage of using local classes?
a) Make program more efficient
b) Makes program execution faster
c) Helps to add extra functionality to a function
d) Helps to add more members to a function

1. Which among the following best describes a nested class?


a) Class inside a class
b) Class inside a function
c) Class inside a package
d) Class inside a structure
2. Which feature of OOP reduces the use of nested classes?
a) Encapsulation
b) Inheritance
c) Binding
d) Abstraction
3. How many categories are nested classes divided into?
a) 2
b) 3
c) 4
d) 5
4. Non-static nested classes have access to _____________ from enclosing class.
a) Private members
b) Protected members
c) Public members
d) All the members
5. Static nested classes doesn’t have access to _________________ from enclosing class.
a) Private members
b) Protected members
c) Public members
d) Any other members
6. The nested class can be declared ___________________
a) Public
b) Private
c) Protected
d) Public, Protected, Private or Package private
7. Use of nested class ____________ encapsulation.
a) Increases
b) Decreases
c) Doesn’t affect
d) Slightly decreases
8. Which among the following is the correct advantage/disadvantage of nested classes?
a) Makes the code more complex
b) Makes the code unreadable
c) Makes the code efficient and readable
d) Makes the code multithreaded
9. How to access static nested classes?
a) OuterClass.StaticNestedClass
b) OuterClass->StaticNestedClass
c) OuterClass(StaticNestedClass)
d) OuterClass[StaticNestedClass]
10. A nested class can have its own static members.
a) True
b) False
11. How to create object of the inner class?
a) OuterClass.InnerClass innerObject = outerObject.new InnerClass();
b) OuterClass.InnerClass innerObject = new InnerClass();
c) InnerClass innerObject = outerObject.new InnerClass();
d) OuterClass.InnerClass = outerObject.new InnerClass();
12. What will be the output of the following code?

public class Test


{
public int a=0;
class innerClass
{
public int a=1;
void innermethod(int x)
{
System.out.println(“value of x = ” + x);
System.out.println(“value of this.x = ” + this.x);
System.out.println(“value of Test.this.x = ” + Test.T=this.x);
}
}
}
public static void main( String args[] )
{
Test t=new Test();
Test.innerClass im=t.new innerClass();
im.innermethod(55);
}

a)

value of x = 55

value of this.x = 0

value of Test.this.x = 1

b)

value of x = 1

value of this.x = 0

value of Test.this.x = 55

c)

value of x = 55

value of this.x = 1

value of Test.this.x = 0

d)

value of x = 0

value of this.x = 55

value of Test.this.x = 1

13. Instance of inner class can exist only _______________ enclosing class.
a) Within
b) Outside
c) Private to
d) Public to
14. If a declaration of a member in inner class has the same name as that in the outer class, then
________________ enclosing scope.
a) Outer declaration shadows inner declaration in
b) Inner declaration shadows outer declaration in
c) Declaration gives compile time error
d) Declaration gives runtime error
15. A static nested class is _____________ class in behavior that is nested in another _________ class.
a) Top level, top level
b) Top level, low level
c) Low level, top level
d) Low level, low level

Passing and returning object

1. In how many ways can an object be passed to a function?


a) 1
b) 2
c) 3
d) 4
2. If an object is passed by value _____________
a) A new copy of object is created implicitly
b) The object itself is used
c) Address of the object is passed
d) A new object is created with new random values
3. Pass by address passes the address of object _________ and pass by reference passes the
address of the object _________
a) Explicitly, explicitly
b) Implicitly, implicitly
c) Explicitly, Implicitly
d) Implicitly, explicitly
4. If an object is passed by reference, the changes made in the function ___________
a) Are reflected to the main object of caller function too
b) Are reflected only in local scope of the called function
c) Are reflected to the copy of the object that is made during pass
d) Are reflected to caller function object and called function object also
5. Constructor function is not called when an object is passed to a function, will its destructor be
called when its copy is destroyed?
a) Yes, depending on code
b) Yes, must be called
c) No, since no constructor was called
d) No, since same object gets used
6. When an object is returned by a function, a _______________ is automatically created to hold the
return value.
a) Temporary object
b) Virtual object
c) New object
d) Data member
7. Is the destruction of temporary object safe (while returning object)?
a) Yes, the resources get free to use
b) Yes, other objects can use the memory space
c) No, unexpected side effects may occur
d) No, always gives rise to exceptions
8. How to overcome the problem arising due to destruction of temporary object?
a) Overloading insertion operator
b) Overriding functions can be used
c) Overloading parenthesis or returning object
d) Overloading assignment operator and defining copy constructor
9. How many objects can be returned at once?
a) Only 1
b) Only 2
c) Only 16
d) As many as required
10. What will be the output of the following code?

Class A
{
int i;
public : A(int n)
{
i=n; cout&lt;&lt;”inside constructor ”;
}
~A()
{
cout&lt;&lt;”destroying ”&lt;&lt;i;
}
void seti(int n)
{
i=n;
}
int geti()
{
return I;
}
};
void t(A ob)
{
cout&lt;&lt;”something ”;
}
int main()
{
A a(1);
t(a);
cout&lt;&lt;”this is i in main ”;
cout&lt;&lt;a.geti();
}

a) inside constructor something destroying 2this is i in main destroying 1


b) inside constructor something this is i in main destroying 1
c) inside constructor something destroying 2this is i in main
d) something destroying 2this is i in main destroying 1
11. It is necessary to return the object if it was passed by reference to a function.
a) Yes, since the object must be same in caller function
b) Yes, since the caller function needs to reflect the changes
c) No, the changes are made automatically
d) No, the changes are made explicitly
12. How many objects can be passed to a function simultaneously?
a) Only 1
b) Only an array
c) Only 1 or an array
d) As many as required
13. If an object is passed by address, will be constructor be called?
a) Yes, to allocate the memory
b) Yes, to initialize the members
c) No, values are copied
d) No, temporary object is created
14. Is it possible that an object of is passed to a function, and the function also have an object of
same name?
a) No, Duplicate declaration is not allowed
b) No, 2 objects will be created
c) Yes, Scopes are different
d) Yes, life span is different
15. Passing an object using copy constructor and pass by value are same.
a) True
b) False

Object reference

1. What is reference to an object?


a) It is address of an object
b) It is address of where the variables and methods of object are stored
c) It is pointer having address of an object
d) It is address of only variables and not the methods of an object
2. Whenever an object is assigned to a variable or passed to a method ________________
a) Actually the objects aren’t used
b) Actually only the objects are used
c) Actually a pointer to an object is used
d) Actually copy of object is used
3. Does use of object reference in assignment or passing means copy of the object is being used?
a) No, because the copy would create a new temporary variable
b) No, because the copy would not help to make changes to main object
c) Yes, because the reference directly means using address
d) Yes, because the reference directly means the constructors are involved
4. What will be the output of the following code?

import java.awt.Point;
class Testing
{
public static void main(String[] args)
{
Point p1,p2;
p1=new Point(100,100);
p2=p1;
p1.x=200;
p1.y=200;
System.out.println(“Point 1: ” + p1.x + ”, “ + p1.y);
System.out.println(“Point 2: ” + p2.x + ”, “ + p2.y);
}
}

a)

Point 1: 100, 100


Point 2: 200, 200

Take Object Oriented Programming Mock Tests - Chapterwise!


Start the Test Now: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

b)

Point 1: 200, 200

Point 2: 100, 100

c)

Point 1: 100, 100

Point 2: 100, 100

d)

Point 1: 200, 200

Point 2: 200, 200

5. Is there any explicit use of pointers in java that would be applicable to objects?
a) Yes, we use reference for this purpose
b) Yes, we use java arrays for this purpose
c) No, implicit pointing is possible
d) No, direct class names should be used
6. Can a super class object give reference to a subclass method?
a) No, it is not possible
b) Maybe, it is possible
c) No, it’s not possible
d) No, It’s not possible in few cases only
7. What will be the output of the following code?

import java.awt.Point;
class Testing
{
public static void main(String[] args)
{
Point t1,t2,t3;
t1=new Point(100,100);
t2=t1;
t3=t1;
t1.x=200;
t1.y=200;
t2.x=300;
t3.y=500;
System.out.println(“Point 1: ” + p1.x + ”, “ + p1.y);
}
}
a) Point 1: 200, 200
b) Point 1: 100,100
c) Point 1: 300, 300
d) Point 1: 300, 500
8. If a reference variable is declared final then _________________
a) It can never be reassigned to refer to a different object
b) It can be assigned to refer to any object anytime
c) It can never be assigned with any object
d) It can be assigned with 2 or more objects simultaneously
9. Which of the members are referred by this pointer usually (Java)?
a) Members of class where this is used
b) Member of the parent class where this is used
c) Members that are passed as argument to the object
d) Pointers are not applicable in java
10. How to refer to method of nested class?
a) enclosingClassObject.innerClassObject.method();
b) innerClassObject.method();
c) method();
d) depends on where the method is being called
11. How many objects can be referenced from the same variables?
a) One at a time
b) Many at a time
c) Many using array name
d) 7 at max at same time
12. Java handles memory dynamically and references are deleted as soon as they are out of
scope.
a) True
b) False
13. Which among the following is true?
a) Object referencing refers to methods address
b) Object referencing refers to variable of object
c) Object referencing points to same address, if assigned by variables
d) Object referencing is used to point methods
14. Invoking a method on a particular object is ____________ sending a message to that object.
a) Different from
b) Same as
c) Somewhat similar
d) Part of
15. Can reference to an object be returned from a method?
a) Yes, always possible
b) Yes, but not always
c) No, never possible
d) No, Not possible because referred element would be destroyed

Memory allocation

1. What does memory allocation for objects mean?


a) Actual creation and memory allocation for object members
b) Creation of member functions
c) Creation of data members for a class
d) Actual creation and data declaration for object members
2. Where is the memory allocated for the objects?
a) HDD
b) Cache
c) RAM
d) ROM
3. When is the memory allocated for an object?
a) At declaration of object
b) At compile time
c) When object constructor is called
d) When object is initialized to another object
4. Using new is type safe as _______________________
a) It require to be specified with type of data
b) It doesn’t require to be specified with type of data
c) It requires the name of data
d) It allocated memory for the data
5. Which of the following function can be used for dynamic memory allocation of objects?
a) malloc()
b) calloc()
c) create()
d) malloc() and calloc()
6. How much memory will be allocated for an object of class given below?
class Test
{
int mark1;
int mark2;
float avg;
char name[10];
};

a) 22 Bytes
b) 24 Bytes
c) 20 Bytes
d) 18 Bytes
7. Which keyword among the following can be used to declare an array of objects in java?
a) new
b) create
c) allocate
d) arr
8. When is the memory allocated for an object gets free?
a) At termination of program
b) When object goes out of scope
c) When main function ends
d) When system restarts
9. Which among the following keyword can be used to free the allocated memory for an object?
a) delete
b) free
c) either delete or free
d) only delete
10. Which function is called whenever an object goes out of scope?
a) Destructor function
b) Constructor function
c) Delete function
d) Free function
11. Which operator can be used to check the size of an object?
a) sizeof(objectName)
b) size(objectName)
c) sizeofobject(objectName)
d) sizedobject(objectName)
12. The memory allocated for an object ____________________
a) Can be only dynamic
b) Can be only static
c) Can be static or dynamic
d) Can’t be done using dynamic functions
13. If an object is declared in a user defined function __________________
a) Its memory is allocated in stack
b) Its memory is allocated in heap
c) Its memory is allocated in HDD
d) Its memory is allocated in cache
14. In java, ____________________ takes care of managing memory for objects dynamically.
a) Free collector
b) Dust collector
c) Memory manager
d) Garbage collector
15. Which operator can be used to free the memory allocated for an object in C++?
a) Free()
b) delete
c) Unallocate
d) Collect

Object array

1. What is an array of objects?


a) An array of instances of class represented by single name
b) An array of instances of class represented by more than one name
c) An array of instances which have more than 2 instances
d) An array of instances which have different types
2. Which among the following is a mandatory condition for array of objects?
a) All the objects should be of different class
b) All the objects should be of same program classes
c) All the objects should be of same class
d) All the objects should have different data
3. What is the type of elements of array of objects?
a) Class
b) Void
c) String
d) Null
4. If array of objects is declared as given below, which is the limitation on objects?

Class_name arrayName[size];

a) The objects will have same values


b) The objects will not be initialized individually
c) The objects can never be initialized
d) The objects will have same data
5. Which is the condition that must be followed if the array of objects is declared without
initialization, only with size of array?
a) The class should have separate constructor for each object
b) The class must have no constructors
c) The class should not have any member function
d) The class must have a default or zero argument constructor
6. When are the array of objects without any initialization useful?
a) When object data is not required just after the declaration
b) When initialization of object data is to be made by the compiler
c) When object data doesn’t matter in the program
d) When the object should contain garbage data
7. If constructor arguments are passed to objects of array then ____________ if the constructors are
overloaded.
a) It is mandatory to pass same number of arguments to all the objects
b) It is mandatory to pass same type of arguments to all the objects
c) It is not mandatory to call same constructor for all the objects
d) It is mandatory to call same constructor for all the constructors
8. How the objects of array can be denoted?
a) Indices
b) Name
c) Random numbers
d) Alphabets
9. The objects in an object array _______________________
a) Can be created without use of constructor
b) Can be created without calling default constructor
c) Can’t be created with use of constructor
d) Can’t be created without calling default constructor
10. The Object array is created in _____________________
a) Heap memory
b) Stack memory
c) HDD
d) ROM
11. If an array of objects is of size 10 and a data value have to be retrieved from 5th object then
________________ syntax should be used.
a) Array_Name[4].data_variable_name;
b) Data_Type Array_Name[4].data_variable_name;
c) Array_Name[4].data_variable_name.value;
d) Array_Name[4].data_variable_name(value);
12. Can we have two dimensional object array?
a) Yes, always
b) Yes, only if primitive type array
c) No, since two indices are impossible
d) No, never
13. From which index does the array of objects start?
a) 0
b) 1
c) 2
d) 3
14. Two dimensional array can’t be initialized with the declaration.
a) True
b) False
15. Is an array of characters always a string?
a) Yes, always
b) Yes, if each character is terminated by null
c) No, since each character is terminated by null
d) No, never

Object use

1. Which among the following is the main use of object?


a) To create instance of a function
b) To create instance of a program
c) To create instance of class
d) To create instance of structures
2. Which among the following is not a property of an object?
a) Identity
b) Properties
c) Attributes
d) Names
3. What is function object?
a) An object with a single function
b) An object with only functions
c) An object with more than one function
d) An object with no functions
4. Immutable object are used ______________________
a) To set up as a fixed state
b) To set up variable object
c) To set up an object of abstract class
d) To set up an object of derived class
5. Which object can be used to contain other objects?
a) First class object
b) Derived class object
c) Container object
d) Enclosure object
6. A factory object is used ______________________
a) To create new classes
b) To create new function
c) To create new data members
d) To create new objects
7. What are singleton objects?
a) The only two objects of a class throughout the program
b) The only object of a class throughout the program
c) The objects that are alive throughout the program
d) The objects that are created and then deleted without use
8. Object cout and cin _________________
a) Can be used directly with << and >> symbols respectively
b) Can be used directly with >> and << symbols respectively
c) Must be used as a function which accepts 2 arguments
d) Must be used as a function which accepts 3 arguments
9. Objects type ____________________
a) Can be changed in runtime
b) Can’t be changed in runtime
c) Can be changed in compile time
d) May or may not get changed
10. An object can be used to represent _________________
a) A real world entity
b) A real function
c) Some real data only
d) Some function only
11. Objects can be used _____________________
a) To access any member of a class
b) To access only public members of a class
c) To access only protected members of a class
d) To access only private members of a class
12. Which among the following is not a use of object?
a) Defining a member function
b) Accessing data members
c) Creating instance of a class
d) Using class members
13. Which object can be used to access the standard input?
a) System.inner
b) cin
c) System.stdin
d) console.input
14. A single object can be used __________________
a) As only two class types at a time
b) As only three class types at a time
c) As only one class type at a time
d) As of as many class types as required
15. If same object name is given to different objects of different class then _____________
a) Its compile time error
b) Its runtime error
c) It’s not an error
d) Program suns smooth

Abstract class
1. Which among the following best describes abstract classes?
a) If a class has more than one virtual function, it’s abstract class
b) If a class have only one pure virtual function, it’s abstract class
c) If a class has at least one pure virtual function, it’s abstract class
d) If a class has all the pure virtual functions only, then it’s abstract class
2. Can abstract class have main() function defined inside it?
a) Yes, depending on return type of main()
b) Yes, always
c) No, main must not be defined inside abstract class
d) No, because main() is not abstract function
3. If there is an abstract method in a class then, ________________
a) Class must be abstract class
b) Class may or may not be abstract class
c) Class is generic
d) Class must be public
4. If a class is extending/inheriting another abstract class having abstract method, then
_______________________
a) Either implementation of method or making class abstract is mandatory
b) Implementation of the method in derived class is mandatory
c) Making the derived class also abstract is mandatory
d) It’s not mandatory to implement the abstract method of parent class
5. Abstract class A has 4 virtual functions. Abstract class B defines only 2 of those member
functions as it extends class A. Class C extends class B and implements the other two member
functions of class A. Choose the correct option below.
a) Program won’t run as all the methods are not defined by B
b) Program won’t run as C is not inheriting A directly
c) Program won’t run as multiple inheritance is used
d) Program runs correctly
6. Abstract classes can ____________________ instances.
a) Never have
b) Always have
c) Have array of
d) Have pointer of
7. We ___________________ to an abstract class.
a) Can create pointers
b) Can create references
c) Can create pointers or references
d) Can’t create any reference, pointer or instance
8. Which among the following is an important use of abstract classes?
a) Header files
b) Class Libraries
c) Class definitions
d) Class inheritance
9. Use of pointers or reference to an abstract class gives rise to which among the following
feature?
a) Static Polymorphism
b) Runtime polymorphism
c) Compile time Polymorphism
d) Polymorphism within methods
10. The abstract classes in java can _________________
a) Implement constructors
b) Can’t implement constructor
c) Can implement only unimplemented methods
d) Can’t implement any type of constructor
11. Abstract class can’t be final in java.
a) True
b) False
12. Can abstract classes have static methods (Java)?
a) Yes, always
b) Yes, but depends on code
c) No, never
d) No, static members can’t have different values
13. It is _________________________ to have an abstract method.
a) Not mandatory for an static class
b) Not mandatory for a derived class
c) Not mandatory for an abstract class
d) Not mandatory for parent class
14. How many abstract classes can a single program contain?
a) At most 1
b) At least 1
c) At most 127
d) As many as required
15. Is it necessary that all the abstract methods must be defined from an abstract class?
a) Yes, depending on code
b) Yes, always
c) No, never
d) No, if function is not used, no definition is required
Template class

1. A template class can have _____________


a) More than one generic data type
b) Only one generic data type
c) At most two data types
d) Only generic type of integers and not characters
2. Which among the following is the proper syntax for the template class?
a) template <typename T1, typename T2>;
b) Template <typename T1, typename T2>;
c) template <typename T> T named(T x, T y){ }
d) Template <typename T1, typename T2> T1 named(T1 x, T2 y){ }
3. Can default arguments be used with the template class?
a) Yes, in some special cases
b) Yes, always
c) No, it must satisfy some specific conditions first
d) No, it can’t be done
4. What is the syntax to use explicit class specialization?
a) template <int> class myClass<>{ }
b) template <int> class myClass<int>{ }
c) template <> class myClass<>{ }
d) template <> class myClass<int>{ }
5. Which is the most significant feature that arises by using template classes?
a) Code readability
b) Ease in coding
c) Code reusability
d) Modularity in code
6. A template class defines the form of a class _____________________ it will operate.
a) With full specification of the data on which
b) With full specification of the functions on which
c) Without full specification of the data on which
d) Without full specification of the functions on which
7. What are the two specializations of I/O template classes in C++?
a) 16-bit character and wide characters
b) 8-bit character and wide characters
c) 32-bit character and locale characters
d) 64-bit characters and locale characters
8. Can typeid() function be used with the object of generic classes?
a) Yes, only if default type is given
b) Yes, always
c) No, generic data can’t be determined
d) No, never possible
9. The _____________ class is a specialization of a more general template class.
a) String
b) Integer
c) Digit
d) Math
10. How is function overloading different from template class?
a) Overloading is multiple function doing same operation, Template is multiple function doing
different operations
b) Overloading is single function doing different operations, Template is multiple function doing
different operations
c) Overloading is multiple function doing similar operation, Template is multiple function doing
identical operations
d) Overloading is multiple function doing same operation, Template is same function doing
different operations
11. What if static members are declared inside template classes?
a) All instances will share the static variable
b) All instances will have their own static variable
c) All the instances will ignore the static variable
d) Program gives compile time error
12. What is the output of following program?

template <typename T>


void test(const T&x)
{
static int count = 0;
cout &lt;&lt; "x = " &lt;&lt; x &lt;&lt; " count = " &lt;&lt; count &lt;&lt; endl;
++count;
return;
}
void main()
{
test<int> (2);
test<int>(2);
test<double>(2.2);
}

a)

x = 2 count = 0

x = 2.2 count = 0

x = 2.2 count = 0

b)

x = 2 count = 0

x = 2 count = 0

x = 2.2 count = 0

c)

x = 2 count = 0

x = 2 count = 1

x = 2.2 count = 0

d)

x = 2 count = 0

x = 2 count = 1

x = 2.2 count = 2

13. If template class is defined, is it necessary to use different types of data for each call?
a) No, not necessary
b) No, but at least two types must be there
c) Yes, to make proper use of template
d) Yes, for code efficiency
14. How many generic types can be given inside a single template class?
a) Only 1
b) Only 3
c) Only 7
d) As many as required
15. Template classes must have at least one static member.
a) True
b) False

Base class

1. Which is most appropriate definition of a base class?


a) It is parent of any of its derived class
b) It is child of one of the parent class
c) It is most basic class of whole program
d) It is class with maximum number of members
2. A base class is also known as _____________ class.
a) Basic
b) Inherited
c) Super
d) Sub
3. An abstract class is always a __________ class.
a) Base
b) Derived
c) Template
d) Nested

4. How many base classes can a single class inherit in java?


a) 1
b) 2
c) 3
d) As many as required
5. How to make a derived class a base class?
a) Change name of the class
b) Use keyword base
c) Make a class derive from it
d) Can’t be done
6. If a base class is being derived by two other classes, which inheritance will that be called?
a) Single
b) Multiple
c) Multi-level
d) Hierarchical
7. Which among the following must be in a base class?
a) Data members
b) Member functions
c) Access specifiers
d) Nothing
8. Which type of members can’t be accessed in derived classes of a base class?
a) Protected
b) Private
c) Public
d) All can be accessed
9. If a class is enclosing more than one class, than it can be called as base class of those classes.
a) True
b) False
10. Base class have ________________ of abstraction.
a) Higher degree
b) Lower degree
c) Intermediate
d) Minimum degree
11. Always the base class constructors are called ___________ constructor of derived class.
a) Before
b) After
c) Along
d) According to priority of
12. Can we call methods of base class using the constructor of the derived class?
a) Yes, always
b) Yes, but not always
c) No, never
d) No, but we can call in some cases
13. If a base class is inherited from another class and then one class derives it, which inheritance
is shown?
a) Multiple
b) Single
c) Hierarchical
d) Multi-level
14. How many base classes can a single derived class have in C++?
a) 1
b) 2
c) 3
d) As many as required
15. If a base class is added with a few new members, its subclass must also be modified.
a) True
b) False
Derived class

1. Which among the following is best definition of a derived class?


a) A child class
b) A class which inherits one or more classes
c) A class with keyword derived
d) A class with more than one constructor
2. Which among the following is inherited by a derived class from base class?
a) Data members only
b) Member functions only
c) All the members except private members
d) All the members of base class
3. If there is a derived class in a program, how many classes must be in that program?
a) 1
b) 2
c) 3
d) 4
4. Which members can never be accessed in derived class from the base class?
a) Private
b) Protected
c) Public
d) All except private
5. How many types of inheritance are supported in C++ for deriving a class?
a) 1
b) 2
c) 3
d) 4
6. How many derived class can a single base class have?
a) 1
b) 2
c) 3
d) As many are required
7. Which among the following is correct?
a) Friend function of derived class can access non-private members of base class
b) Friend function of base class can access derived class members
c) Friend function of derived class can access members of only derived class
d) Friend function can access private members of base class of a derived class
8. If a class is being derived using more than two base classes, which inheritance will be used?
a) Single
b) Multi-level
c) Hierarchical
d) Multiple
9. Derived class is also known as ______________ class.
a) Subclass
b) Small class
c) Big class
d) Noticeable class
10. If class A is derived from another derived class B which is derived from class C, which class will
have maximum level of abstraction?
a) Class A
b) Class B
c) Class C
d) All have the same level of abstraction
11. If base class is an abstract class then derived class ______________ the undefined functions.
a) Must define
b) Must become another abstract class or define
c) Must become parent class for
d) Must implement 2 definitions of
12. How many classes can be derived from a derived class?
a) Only 1
b) At most 1
c) At least 1
d) As many as required
13. The members of a derived class can never be derived.
a) True
b) False
14. Which feature is not related to the derived classes among the following?
a) Inheritance
b) Encapsulation
c) Run time memory management
d) Compile time function references
15. Deriving a class in such a way that that the base class members are not available for further
inheritance is known as ___________________
a) Public inheritance
b) Protected inheritance
c) Protected or private inheritance
d) Private inheritance

Class use

1. Which among the following is the main characteristic of class?


a) Inheritance
b) Encapsulation
c) Polymorphism
d) Object creation
2. To group all the brands of cars, what should be used?
a) Class
b) Structure
c) Function
d) Object
3. If a class have two data members and two functions to add those two numbers and to subtract
them, which among the following is most efficient if the programmer wants to implement
multiplication too?
a) Define a public function which multiplies two numbers
b) Define a public function that returns values of two data members
c) Define a private function which multiplies two numbers
d) Define a private function that returns values of two data members
4. If a database have to be maintained using OOP, to store the details of each employee in a
company, which would be the best choice among the following?
a) Define a class to store details of each employee
b) Define a structure to store details of each employee
c) Define separate variable for each detail
d) Define a generic type to store string and number details
5. Which class represents the most abstracted information?
a) Nested
b) Derived
c) Enclosed
d) Base
6. Which among the following is an advantage of using classes over structures of C?
a) Functions are restricted
b) Functions can’t be defined
c) Functions can also be encapsulated
d) Functions can have more security
7. Which among the following is a feature of class?
a) Object orientation
b) Procedure orientation
c) Both object and procedure orientation
d) Neither object nor procedure orientation
8. Class is _____________ of an object.
a) Basic function definition
b) Detailed description with values
c) Blueprint
d) Set of constant values
9. In which case the classes can be used to make the more efficient program?
a) To define a function that is called frequently in a program
b) To structure data that is most similar
c) To group the most similar data and operations
d) To define a blueprint that shows memory location of data
10. What is the use of inbuilt classes?
a) Provide predefined data
b) Provide predefined functions
c) Provide predefined data and functions
d) Provide predeclared data to be overridden
11. Which feature is exhibited by the inbuilt classes?
a) Code reusability
b) Code efficiency
c) Code readability
d) Code reusability, efficiency and readability
12. Why do we use user defined classes?
a) To design a user intended code
b) To model real world objects
c) To design the interfaces
d) To model the functions
13. Why do classes use accessor methods?
a) To make public data accessible to client
b) To make public data private to client
c) To make private data public for whole program
d) To make private data accessible to the client
14. Why do classes use mutator methods?
a) Allows client to modify the program
b) Allows client to modify/write the private members
c) Allows servers to access all the private data
d) Allows servers to access only protected members
15. Which among the following is the most abstract form of class?
a) Cars
b) BMW cars
c) Big cars
d) Small cars

Inheritance

1. Which among the following best describes the Inheritance?


a) Copying the code already written
b) Using the code already written once
c) Using already defined functions in programming language
d) Using the data and functions into derived segment
2. How many basic types of inheritance are provided as OOP feature?
a) 4
b) 3
c) 2
d) 1
3. Which among the following best defines single level inheritance?
a) A class inheriting a derived class
b) A class inheriting a base class
c) A class inheriting a nested class
d) A class which gets inherited by 2 classes
4. Which among the following is correct for multiple inheritance?
a) class student{public: int marks;}s; class stream{int total;}; class topper:public student, public
stream{ };
b) class student{int marks;}; class stream{ }; class topper: public student{ };
c) class student{int marks;}; class stream:public student{ };
d) class student{ }; class stream{ }; class topper{ };
5. Which programming language doesn’t support multiple inheritance?
a) C++ and Java
b) C and C++
c) Java and SmallTalk
d) Java
6. Which among the following is correct for a hierarchical inheritance?
a) Two base classes can be used to be derived into one single class
b) Two or more classes can be derived into one class
c) One base class can be derived into other two derived classes or more
d) One base class can be derived into only 2 classes
7. Which is the correct syntax of inheritance?
a) class derived_classname : base_classname{ /*define class body*/ };
b) class base_classname : derived_classname{ /*define class body*/ };
c) class derived_classname : access base_classname{ /*define class body*/ };
d) class base_classname :access derived_classname{ /*define class body*/ };
8. Which type of inheritance leads to diamond problem?
a) Single level
b) Multi-level
c) Multiple
d) Hierarchical
9. Which access type data gets derived as private member in derived class?
a) Private
b) Public
c) Protected
d) Protected and Private
10. If a base class is inherited in protected access mode then which among the following is true?
a) Public and Protected members of base class becomes protected members of derived class
b) Only protected members become protected members of derived class
c) Private, Protected and Public all members of base, become private of derived class
d) Only private members of base, become private of derived class
11. Members which are not intended to be inherited are declared as ________________
a) Public members
b) Protected members
c) Private members
d) Private or Protected members
12. While inheriting a class, if no access mode is specified, then which among the following is
true? (in C++)
a) It gets inherited publicly by default
b) It gets inherited protected by default
c) It gets inherited privately by default
d) It is not possible
13. If a derived class object is created, which constructor is called first?
a) Base class constructor
b) Derived class constructor
c) Depends on how we call the object
d) Not possible
14. The private members of the base class are visible in derived class but are not accessible
directly.
a) True
b) False
15. How can you make the private members inheritable?
a) By making their visibility mode as public only
b) By making their visibility mode as protected only
c) By making their visibility mode as private in derived class
d) It can be done both by making the visibility mode public or protected

1. How many types of inheritance are possible in C++?


a) 2
b) 3
c) 4
d) 5
2. Which among the following is true?
a) Java supports all types of inheritance
b) Java supports multiple inheritance
c) Java doesn’t support multiple inheritance
d) Java doesn’t support inheritance
3. Which type of inheritance is illustrated by the following code?

class student{ public: int marks; };


class topper: public student { public: char grade; };
class average{ public: int makrs_needed; };
class section: public average{ public: char name[10]; };
class overall: public average{ public: int students; };

a) Single level
b) Multilevel and single level
c) Hierarchical
d) Hierarchical and single level
4. Which among the following best describes multiple inheritance?
a) Two classes being parent of any other classes
b) Three classes being parent of other classes
c) More than one class being parent of other child classes
d) More than one class being parent of single child
5. How many types of inheritance can be used at a time in a single program?
a) Any two types
b) Any three types
c) Any 4 types
d) Any type, any number of times
6. Which type of inheritance results in the diamond problem?
a) Single level
b) Hybrid
c) Hierarchical
d) Multilevel
7. If 6 classes uses single level inheritance with pair classes (3 pairs), which inheritance will this be
called?
a) Single
b) Multiple
c) Hierarchical
d) Multilevel
8. Which among the following is correct for the following code?

class A
{
public : class B
{
public : B(int i): data(i)
{
}
int data;
}
};
class C: public A
{
class D:public A::B{ };
};

a) Multi-level inheritance is used, with nested classes


b) Multiple inheritance is used, with nested classes
c) Single level inheritance is used, with enclosing classes
d) Single level inheritance is used, with both enclosing and nested classes
9. Which among the following is false?
a) If one class inherits the inherited class in single level inheritance, it is multi-level inheritance
b) Hybrid inheritance always contains multiple inheritance
c) Hierarchical inheritance involves inheriting same class into more than one classes
d) Hybrid inheritance can involve any types of inheritance together
10. If class A has two nested classes B and C. Class D has one nested class E, and have inherited
class A. If E inherits B and C, then ________________
a) It shows multiple inheritance
b) It shows hierarchical inheritance
c) It shows multiple inheritance
d) Multiple inheritance among nested classes, and single level for enclosing classes
11. In hierarchical inheritance, all the classes involve some kind of inheritance.
a) True
b) False
12. Which type of inheritance cannot involve private inheritance?
a) Single level
b) Multiple
c) Hybrid
d) All types can have private inheritance
13. How many classes can be inherited by a single class in multiple inheritance (C++)?
a) Only 2
b) Only 27
c) Only 1024
d) Any number of classes can be inherited
14. How many classes can be inherited by a single class in java?
a) Only 1
b) Only 27
c) Only 255
d) Only 1024
15. If multi-level inheritance is used, First class B inherits class A, then C inherits B and so on. Till
how many classes can this go on?
a) Only till class C
b) Only till class J
c) Only till class Z
d) There is no limit

1. Which among the following defines single level inheritance?


a) One base class derives another class
b) One derived class inherits from one base class
c) One base class inherits from one derived class
d) One derived class derives from another derived class
2. If class A and class B are derived from class C and class D, then ________________
a) Those are 2 pairs of single inheritance
b) That is multilevel inheritance
c) Those is enclosing class
d) Those are all independent classes
3. If single inheritance is used, program will contain ________________
a) At least 2 classes
b) At most 2 classes
c) Exactly 2 classes
d) At most 4 classes
4. Single level inheritance supports _____________ inheritance.
a) Runtime
b) Compile time
c) Multiple inheritance
d) Language independency
5. Which method in the code below is single level inherited?

class A
{
protected int a, b;
public: void show()
{
cout&lt;&lt;a&lt;&lt;b;
}
};
class B: public A
{
public: void disp()
{
cout&lt;&lt;a++&lt;&lt;b++;
}
};
class C: private A, public B
{
void avg()
{
cout&lt;&lt;(a+b)/2;
}
};

a) Class A
b) Class B
c) Class C
d) None
6. If single level inheritance is used and an abstract class is created with some undefined
functions, can its derived class also skip some definitions?
a) Yes, always possible
b) Yes, possible if only one undefined function
c) No, at least 2 undefined functions must be there
d) No, the derived class must implement those methods
7. Which among the following is false for single level inheritance?
a) There can be more than 2 classes in program to implement single inheritance
b) There can be exactly 2 classes to implement single inheritance in a program
c) There can be more than 2 independent classes involved in single inheritance
d) The derived class must implement all the abstract method if single inheritance is used
8. Which concept will result in derived class with more features (consider maximum 3 classes)?
a) Single inheritance
b) Multiple inheritance
c) Multilevel inheritance
d) Hierarchical inheritance
9. Single level inheritance is safer than _____________
a) Multiple inheritance
b) Interfaces
c) Implementations
d) Extensions
10. Which language doesn’t support single level inheritance?
a) Java
b) C++
c) Kotlin
d) All languages support it
11. What is the output of the following program?

class A
{
protected: int a,b;
public: void disp()
{
cout&lt;&lt;a&lt;&lt;b;
}
};
class B:public A
{
int x,y;
};

a) Garbage value
b) Compile time error
c) Runtime error
d) Runs but gives random values as output
12. What is the output of the following program?

class A
{
float sal=40000;
}
class B extends A
{
int salBonus=10000;
public static void main(String args[])
{
B p=new B();
System.out.println("B salary is:"+p.sal);
System.out.println("Bonus of B is:"+p.bonus);
}
}

a)

B salary is: 4000.0

Bonus of B is: 10000

b)

B salary is 10000

Bonus of B is: 4000.0

c) Compile time error


d) Runtime error
13. Single level inheritance will be best for___________
a) Inheriting a class which performs all the calculations
b) Inheriting a class which can print all the calculation results
c) Inheriting a class which can perform and print all calculations
d) Inheriting all the classes for different calculations
14. Which constructor will be called first from the classes involved in single inheritance from
object of derived class?
a) Base class constructor
b) Derived class constructor
c) Both class constructors at a time
d) Runtime error
15. If base class contains 2 nested classes, will it be possible to implement single level
inheritance?
a) Yes, always
b) Yes, only if derived class also have nested classes
c) No, it will use more than 2 classes which is wrong
d) No, never

1. Which among the following best defines multilevel inheritance?


a) A class derived from another derived class
b) Classes being derived from other derived classes
c) Continuing single level inheritance
d) Class which have more than one parent
2. If there are 5 classes, E is derived from D, D from C, C from B and B from A. Which class
constructor will be called first if the object of E or D is created?
a) A
b) B
c) C
d) A and B
3. If there are 3 classes. Class C is derived from class B and B is derived from A, Which class
destructor will be called at last if object of C is destroyed.
a) A
b) B
c) C
d) All together
4. Which Class is having highest degree of abstraction in multilevel inheritance of 5 levels?
a) Class at 1st level
b) Class 2nd last level
c) Class at 5th level
d) All with same abstraction
5. If all the classes use private inheritance in multilevel inheritance then ______________
a) It will not be called multilevel inheritance
b) Each class can access only non-private members of its parent
c) Each subsequent class can access all members of previous level parent classes
d) None of the members will be available to any other class
6. Multilevel inheritance allows _________________ in the program.
a) Only 7 levels of inheritance
b) At least 7 levels of inheritance
c) At most 16 levels of inheritance
d) As many levels of inheritance as required
7. What is the minimum number of levels for a implementing multilevel inheritance?
a) 1
b) 2
c) 3
d) 4
8. In multilevel inheritance one class inherits _______________
a) Only one class
b) More than one class
c) At least one class
d) As many classes as required
9. All the classes must have all the members declared private to implement multilevel inheritance.
a) True
b) False
10. Can abstract classes be used in multilevel inheritance?
a) Yes, always
b) Yes, only one abstract class
c) No, abstract class doesn’t have constructors
d) No, never
11. How many abstract classes can be used in multilevel inheritance?
a) Only 1
b) Only 2
c) At least one less than number of levels
d) Can’t be used
12. If all the classes used parameterized constructors and no default constructor then ___________
a) The object of lower level classes can’t be created
b) Object of lower level classes must call parent class constructors explicitly
c) Object of lower level classes must define all the default constructors
d) Only object of first class can be created, which is first parent
13. In multilevel inheritance, which is the most significant feature of OOP used?
a) Code readability
b) Flexibility
c) Code reusability
d) Code efficiency
14. Does following code show multiple inheritance?

class A
{
int a;
};
class B
{
int b;
};
class C:public A, public B
{
int c;
};
class D:public C
{
int d;
};

a) Yes, class C and class D


b) Yes, All together it’s multilevel
c) No, 4 classes are used
d) No, multiple inheritance is used with class A, B and C
15. Is it compulsory for all the classes in multilevel inheritance to have constructors defined
explicitly if only last derived class object is created?
a) Yes, always
b) Yes, to initialize the members
c) No, it not necessary
d) No, Constructor must not be defined

1. Multiple inheritance is ____________________


a) When a class is derived from another class
b) When a class is derived from two or more classes
c) When a class is derived from other two derived classes
d) When a class is derived from exactly one class
2. Which problem arises due to multiple inheritance, if hierarchical inheritance is used previously
for its base classes?
a) Diamond
b) Circle
c) Triangle
d) Loop
3. How many classes should a program contain to implement the multiple inheritance?
a) Only 1
b) At least 1
c) At least 3
d) Exactly 3
4. Which programming language restricts the use of multiple inheritance?
a) C++
b) PHP
c) SmallTalk
d) Java
5. Is it possible to have all the abstract classes as base classes of a derived class from those?
a) Yes, always
b) Yes, only if derived class implements all the methods
c) No, because abstract classes doesn’t have constructors
d) No, never
6. If class A inherits class B and class C as “class A: public class B, public class C {// class body ;}; ”,
which class constructor will be called first?
a) Class A
b) Class B
c) Class C
d) All together
7. Why does diamond problem arise due to multiple inheritance?
a) Methods with same name creates ambiguity and conflict
b) Methods inherited from the superclass may conflict
c) Derived class gets overloaded with more than two class methods
d) Derived class can’t distinguish the owner class of any derived method
8. How many base classes can a derived class have which is implementing multiple inheritance?
a) Only 2
b) At least 2
c) At most 2
d) As many as required
9. How to overcome diamond problem?
a) Using alias name
b) Using seperate derived class
c) Using virtual keyword with same name function
d) Can’t be done
10. When multiple inheritance is used, which class object should be used in order to access all the
available members of parent and derived class?
a) Derived class object
b) Parent class objects
c) Use Abstract derived class
d) Derive a class from derived class
11. If all the members of all the base classes are private then _____________
a) There won’t be any use of multiple inheritance
b) It will make those members public
c) Derived class can still access them in multiple inheritance
d) Compile time error
12. Is it compulsory to have constructor for all the classes involved in multiple inheritance?
a) Yes, always
b) Yes, only if no abstract class is involved
c) No, only classes being used should have a constructor
d) No, they must not contain constructors
13. If a class contains 2 nested class and is being inherited by another class, will there be any
multiple inheritance?
a) No, only single level inheritance is used
b) No, only multilevel inheritance is used
c) Yes, because 3 classes are involved
d) Yes, because more than 1 classes are being derived
14. Which members can’t be accessed in derived class in multiple inheritance?
a) Private members of base
b) Public members of base
c) Protected members of base
d) All the members of base
15. Can the derived class be made abstract if multiple inheritance is used?
a) No, because other classes must be abstract too
b) Yes, if all the functions are implemented
c) Yes, if all the methods are predefined
d) No, since constructors won’t be there

1. Which among the following is best to define hierarchical inheritance?


a) More than one classes being derived from one class
b) More than 2 classes being derived from single base class
c) At most 2 classes being derived from single base class
d) At most 1 class derived from another class
2. Do members of base class gets divided among all of its child classes?
a) Yes, equally
b) Yes, depending on type of inheritance
c) No, it’s doesn’t get divided
d) No, it may or may not get divided
3. Each class can inherit the base class ________________
a) Independently using any inheritance
b) Independently with private inheritance only
c) With same type of inheritance
d) With each class using different inheritance only
4. How many classes must be there to implement hierarchical inheritance?
a) Exactly 3
b) At least 3
c) At most 3
d) At least 1
5. Base class _______________
a) Can be made abstract
b) Can’t be made abstract
c) Must be abstract
d) If made abstract, compile time error
6. Which access specifiers should be used so that all the derived classes restrict further
inheritance of base class members?
a) Private
b) Public
c) Protected
d) Any inheritance type can be used
7. Which class uses hierarchical inheritance in following code?

class A
{
int a;
};
class B:class A
{
int b;
};
class C:class A,class B
{
int c;
};
class D:class A
{
int d;
};

a) Class A, B, C
b) Class B, C, D
c) Class A, C, D
d) Class D, A, B
8. Which among the following is correct for following code?

abstract class A
{
public Int a;
public void disp();
};
class B:public A
{
public: void dis()
{
court&lt;&lt;a;
}
};
class C:private A
{
public void incr()
{
a++;
}
}
void main()
{
B b.disp();
}

a) Compile time error


b) Runtime error
c) Program runs and o/p is 0
d) Program runs and o/p is garbage value
9. How many classes can be derived from the base class using hierarchical inheritance?
a) As many as required
b) Only 7
c) Only 3
d) Up to 127
10. If one class have derived the base class privately then another class can’t derive the base class
publically.
a) True
b) False
11. Which among the following is true?
a) Hierarchical inheritance is subset of multiple inheritances
b) Hierarchical inheritance is strongest inheritance type
c) Hierarchical inheritance uses only 2 classes for implementation
d) Hierarchical inheritance allows inheritance of common features to more than one class
12. Hierarchical inheritance can be a subset of _________________
a) Hybrid inheritance
b) Multiple inheritance
c) Single level inheritance
d) Multilevel inheritance
13. Which type of inheritance is most suitable for inheriting Same syllabus into different colleges
with different streams?
a) Multiple
b) Single
c) Hierarchical
d) Multilevel
14. Which class constructor is called first when an object of derived class is created?
a) Base class constructor
b) Derived class constructor
c) Firstly created derived class constructor
d) Last created derived class constructor
15. All the derived classes can access only a few members of base class that other derived classes
can’t access at same time, in hierarchical inheritance.
a) True
b) False

1. Which among the following best defines the hybrid inheritance?


a) Combination of two or more inheritance types
b) Combination of same type of inheritance
c) Inheritance of more than 7 classes
d) Inheritance involving all the types of inheritance
2. How many types of inheritance should be used for hybrid?
a) Only 1
b) At least 2
c) At most two
d) Always more than 2
3. If single inheritance is used with class A and B. A is base class. Then class C, D and E where C is
base class and D is derived from C, then E is derived from D. Class C is made to inherit from class
B. Which is the resultant type?
a) Single level
b) Multilevel
c) Hybrid
d) Multiple
4. Diamond problem includes ____________________ hybrid inheritance.
a) Hierarchical and Multiple
b) Hierarchical and Hierarchical
c) Multiple and Multilevel
d) Single, Hierarchical and Multiple
5. If __________________ inheritance is done continuously, it is similar to tree structure.
a) Hierarchical
b) Multiple
c) Multilevel
d) Hierarchical and Multiple
6. Which amongst the following is true for hybrid inheritance?
a) Constructor calls are in reverse
b) Constructor calls are priority based
c) Constructor of only derived class is called
d) Constructor calls are usual
7. Which type of inheritance must be used so that the resultant is hybrid?
a) Multiple
b) Hierarchical
c) Multilevel
d) None
8. The private member’s are made public to all the classes in inheritance.
a) True
b) False
9. If hierarchical inheritance requires to inherit more than one class to single class, which syntax
is correct? (A, B, C are class names)
a) hierarchical class A: public B, public C
b) multiple class A: public B, public C
c) many class A: public B, public C
d) class A: public B, public C
10. What is the maximum number of classes allowed in hybrid inheritance?
a) 7
b) 127
c) 255
d) As many as required
11. What is the minimum number of classes to be there in a program implementing hybrid
inheritance?
a) 2
b) 3
c) 4
d) No limit
12. If object of lowest level class is created (last derived class) ________________ of its parent class
constructors are called.
a) Few
b) All
c) Only parent and parent
d) Base and Derived
13. If hybrid inheritance is used, it mostly shows _______________ feature of OOP.
a) Flexibility
b) Reusability
c) Efficiency
d) Code readability
14. The sequence of destructors being called while using hybrid inheritance is ____________
a) Reverse of constructors being called
b) Reverse of classes being made
c) Reverse of objects being created
d) Reverse of code calling objects
15. Overloading operators are possible only by using hybrid inheritance.
a) True
b) False

Virtual function

1. Virtual function is ______ class function which expected to be redefined in ______ class, so that
when reference is made to derived class object using pointer then we can call virtual function to
execute ________ class definition version.
a) Base, derived, derived
b) Derived, Derived, Derived
c) Base, derived, base
d) Base, base, derived
2. What does a virtual function ensure for an object, among the following?
a) Correct method is called, regardless of the class defining it
b) Correct method is called, regardless of the object being called
c) Correct method is called, regardless of the type of reference used for function call
d) Correct method is called, regardless of the type of function being called by objects
3. Virtual functions are mainly used to achieve _____________
a) Compile time polymorphism
b) Interpreter polymorphism
c) Runtime polymorphism
d) Functions code polymorphism
4. Which keyword is used to declare virtual functions?
a) virtual
b) virt
c) anonymous
d) virtually
5. Where the virtual function should be defined?
a) Twice in base class
b) Derived class
c) Base class and derived class
d) Base class
6. The resolving of virtual functions is done at ______________
a) Compile time
b) Interpret time
c) Runtime
d) Writing source code
7. In which access specifier should a virtual function be defined?
a) Private
b) Public
c) Protected
d) Default
8. Virtual functions can never be made _______________
a) Static function
b) Parameterized function
c) Default argument function
d) Zero parameter function
9. Virtual functions can’t be made friend function of other classes.
a) True
b) False
10. Which is a must condition for virtual function to achieve runtime polymorphism?
a) Virtual function must be accessed with direct name
b) Virtual functions must be accessed using base class object
c) Virtual function must be accessed using pointer or reference
d) Virtual function must be accessed using derived class object only
11. Which among the following is true for virtual functions?
a) Prototype must be different in base and derived class
b) Prototype must be same in base class and derived class
c) Prototype must be given only in base class
d) Prototype must have different signature in base and derived class
12. The virtual functions must be declared and defined in _____________ class and overridden in
___________ class.
a) Base, base
b) Derived, derived
c) Derived, base
d) Base, derived
13. It is __________ to redefine the virtual function in derived class.
a) Necessary
b) Not necessary
c) Not acceptable
d) Good practice
14. Which among the following is true?
a) A class may have virtual destructor but not virtual constructor
b) A class may have virtual constructor but not virtual destructor
c) A class may have virtual constructor and virtual constructor
d) A class may have either virtual destructor or virtual constructor
15. If virtual function of base class is redefined in derived class then ________________
a) It must be declared virtual in derived class also
b) It may or may not be declared virtual in derived class
c) It can must not be declared virtual in derived class
d) It must be declared normally in derived class

Abstract class

1. Which among the following best defines the abstract methods?


a) Functions declared and defined in base class
b) Functions only declared in base class
c) Function which may or may not be defined in base class
d) Function which must be declared in derived class
2. Which among the following is true?
a) The abstract functions must be only declared in derived classes
b) The abstract functions must not be defined in derived classes
c) The abstract functions must be defined in base and derived class
d) The abstract functions must be defined either in base or derived class
3. How are abstract functions different from the abstract functions?
a) Abstract must not be defined in base class whereas virtual function can be defined
b) Either of those must be defined in base class
c) Different according to definition
d) Abstract functions are faster
4. Which among the following is correct?
a) Abstract functions should not be defined in all the derived classes
b) Abstract functions should be defined only in one derived class
c) Abstract functions must be defined in base class
d) Abstract functions must be defined in all the derived classes
5. It is ____________________ to define the abstract functions.
a) Mandatory for all the classes in program
b) Necessary for all the base classes
c) Necessary for all the derived classes
d) Not mandatory for all the derived classes
6. The abstract function definitions in derived classes is enforced at _________
a) Runtime
b) Compile time
c) Writing code time
d) Interpreting time
7. What is this feature of enforcing definitions of abstract function at compile time called?
a) Static polymorphism
b) Polymorphism
c) Dynamic polymorphism
d) Static or dynamic according to need
8. What is the syntax for using abstract method?
a) <access-modifier>abstract<return-type>method_name (parameter)
b) abs<return-type>method name (parameter)
c) <access-modifier>abstract return-type method name (parameter)
d) <access-modifier>abstract <returning> method name (parameter)
9. If a function declared as abstract in base class doesn’t have to be defined in derived class then
______
a) Derived class must define the function anyhow
b) Derived class should be made abstract class
c) Derived class should not derive from that base class
d) Derived class should not use that function
10. Static methods can’t be made abstract in java.
a) True
b) False
11. Which among the following is true?
a) Abstract methods can be static
b) Abstract methods can be defined in derived class
c) Abstract methods must not be static
d) Abstract methods can be made static in derived class
12. Which among the following is correct for abstract methods?
a) It must have different prototype in the derived class
b) It must have same prototype in both base and derived class
c) It must have different signature in derived class
d) It must have same return type only
13. If a class have all the abstract methods the class will be known as ___________
a) Abstract class
b) Anonymous class
c) Base class
d) Derived class
14. The abstract methods can never be ___________ in a base class.
a) Private
b) Protected
c) Public
d) Default
15. The abstract method definition can be made ___________ in derived class.
a) Private
b) Protected
c) Public
d) Private, public, or protected

Member function

1. How many types of member functions are possible in general?


a) 2
b) 3
c) 4
d) 5
2. Simple member functions are ______________________
a) Ones defined simply without any type
b) Ones defined with keyword simple
c) Ones that are implicitly provided
d) Ones which are defined in all the classes
3. What are static member functions?
a) Functions which use only static data member but can’t be accessed directly
b) Functions which uses static and other data members
c) Functions which can be accessed outside the class with the data members
d) Functions using only static data and can be accessed directly in main() function
4. How can static member function can be accessed directly in main() function?
a) Dot operator
b) Colon
c) Scope resolution operator
d) Arrow operator
5. Correct syntax to access the static member functions from the main() function is ______________
a) classObject::functionName();
b) className::functionName();
c) className:classObject:functionName();
d) className.classObject:functionName();
6. What are const member functions?
a) Functions in which none of the data members can be changed in a program
b) Functions in which only static members can be changed
c) Functions which treat all the data members as constant and doesn’t allow changes
d) Functions which can change only the static members
7. Which among the following best describes the inline member functions?
a) Functions defined inside the class only
b) Functions with keyword inline only
c) Functions defined outside the class
d) Functions defined inside the class or with the keyword inline
8. What are friend member functions (C++)?
a) Member function which can access all the members of a class
b) Member function which can modify any data of a class
c) Member function which doesn’t have access to private members
d) Non-member functions which have access to all the members (including private) of a class
9. What is the syntax of a const member function?
a) void fun() const {}
b) void fun() constant {}
c) void const fun() {}
d) const void fun(){}
10. Which keyword is used to make a nonmember function as friend function of a class?
a) friendly
b) new
c) friend
d) connect
11. Member functions _____________________
a) Must be defined inside class body
b) Can be defined inside class body or outside
c) Must be defined outside the class body
d) Can be defined in another class
12. All type of member functions can’t be used inside a single class.
a) True
b) False
13. Which among the following is true?
a) Member functions can never be private
b) Member functions can never be protected
c) Member functions can never be public
d) Member functions can be defined in any access specifier
14. Which keyword is used to define the static member functions?
a) static
b) stop
c) open
d) state
15. Which keyword is used to define the inline member function?
a) no keyword required
b) inline
c) inlined
d) line

1. Which among the following are valid ways of overloading the operators?
a) Only using friend function
b) Only using member function
c) Either member functions or friend functions can be used
d) Operators can’t be overloaded
2. Which among the following is mandatory condition for operators overloading?
a) Overloaded operator must be member function of the left operand
b) Overloaded operator must be member function of the right operand
c) Overloaded operator must be member function of either left or right operand
d) Overloaded operator must not be dependent on the operands
3. When the operator to be overloaded becomes the left operand member then ______________
a) The right operand acts as implicit object represented by *this
b) The left operand acts as implicit object represented by *this
c) Either right or left operand acts as implicit object represented by *this
d) *this pointer is not applicable in that member function
4. If the left operand is pointed by *this pointer, what happens to other operands?
a) Other operands are passed as function return type
b) Other operands are passed to compiler implicitly
c) Other operands must be passed using another member function
d) Other operands are passed as function arguments
5. If a friend overloaded operator have to be changed to member overloaded operator, which
operator should be used with the class name?
a) Scope resolution operator
b) Colon
c) Arrow operator
d) Dot operator
6. What is the syntax to overload an operator?
a) className::operator<operatorSymbol>(parameters)
b) className:operator<operatorSymbol>(parameters)
c) className.operator<operatorSymbol>(paramteres)
d) className->operator<operatorSymbol>(parameters)
7. Why the left parameter is removed from parameter list?
a) Because it is of no use
b) Because it is never used in definitions
c) Because it becomes parameter pointed by *this
d) Because it can’t be referred by *this pointer
8. Which object’s members can be called directly while overloading operator function is used (In
function definition)?
a) Left operand members
b) Right operand members
c) All operand members
d) None of the members
9. If left operand member is specified directly in the function definition, which is the correct
implicit conversion of that syntax?
a) *this className
b) *this parameterObject
c) *this returnedObject
d) *this object
10. When the friend operator overloading is converted into member operator overloading
_______________
a) Two parameters of friend function remains same parameters in member operator overloading
b) Two parameters of friend function becomes only one parameter of member function
c) Two parameters of friend function are removed while using member function
d) Two parameters of friend function are made 4 in member operator overloading
11. Where in the parameter list is the implicit *this is added?
a) Right most parameter
b) Anywhere in parameter list
c) Left most parameter
d) Not added to parameter list
12. Which operator among the following can be overloading using only member function?
a) Assignment operator
b) Addition operator
c) Subtraction operator
d) Multiplication and division operator
13. Which operator among the following can be overloaded using both friend function and
member function?
a) Assignment operator
b) Subscript
c) Member selection (arrow operator)
d) Modulus operator
14. All the operators can be overloaded using the member function operator overloading.
a) True
b) False
15. Which operator among the following must be overloaded using the friend function?
a) << operator only
b) >> operator only
c) Both << and >> operators
d) It’s not mandatory to use friend function in any case
1. What does memory allocation for objects mean?
a) Actual creation and memory allocation for object members
b) Creation of member functions
c) Creation of data members for a class
d) Actual creation and data declaration for object members
2. Where is the memory allocated for the objects?
a) HDD
b) Cache
c) RAM
d) ROM
3. When is the memory allocated for an object?
a) At declaration of object
b) At compile time
c) When object constructor is called
d) When object is initialized to another object
4. Using new is type safe as _______________________
a) It require to be specified with type of data
b) It doesn’t require to be specified with type of data
c) It requires the name of data
d) It allocated memory for the data
5. Which of the following function can be used for dynamic memory allocation of objects?
a) malloc()
b) calloc()
c) create()
d) both malloc() and calloc()
6. How much memory will be allocated for an object of class given below?

class Test{
int mark1;
int mark2;
float avg;
char name[10];
};

a) 22 Bytes
b) 24 Bytes
c) 20 Bytes
d) 18 Bytes
7. Which keyword among the following can be used to declare an array of objects in java?
a) new
b) create
c) allocate
d) arr
8. When is the memory allocated for an object gets free?
a) At termination of program
b) When object goes out of scope
c) When main function ends
d) When system restarts
9. Which among the following keyword can be used to free the allocated memory for an object?
a) delete
b) free
c) either delete or free
d) only delete
10. Which function is called whenever an object goes out of scope?
a) Destructor function
b) Constructor function
c) Delete function
d) Free function
11. Which operator can be used to check the size of an object?
a) sizeof(objectName)
b) size(objectName)
c) sizeofobject(objectName)
d) sizedobject(objectName)

12. The memory allocated for an object ____________________


a) Can be only dynamic
b) Can be only static
c) Can be static or dynamic
d) Can’t be done using dynamic functions
13. If an object is declared in a user defined function __________________
a) Its memory is allocated in stack
b) Its memory is allocated in heap
c) Its memory is allocated in HDD
d) Its memory is allocated in cache
14. In java ______________ takes care of managing memory for objects dynamically.
a) Free collector
b) Dust collector
c) Memory manager
d) Garbage collector
15. Which operator can be used to free the memory allocated for an object in C++?
a) Free()
b) delete
c) Unallocate
d) Collect

1. Which among the following best describes member function overriding?


a) Member functions having same name in base and derived classes
b) Member functions having same name in base class only
c) Member functions having same name in derived class only
d) Member functions having same name and different signature inside main function
2. Which among the following is true?
a) Inheritance must not be using when overriding is used
b) Overriding can be implemented without using inheritance
c) Inheritance must be done, to use overriding are overridden
d) Inheritance is mandatory only if more than one functions
3. Which is the correct condition for function overriding?
a) The declaration must not be same in base and derived class
b) The declaration must be exactly the same in base and derived class
c) The declaration should have at least 1 same argument in declaration of base and derived class
d) The declaration should have at least 1 different argument in declaration of base and derived
class
4. Exactly same declaration in base and derived class includes______________
a) Only same name
b) Only same return type and name
c) Only same return type and argument list
d) All the same return type, name and parameter list
5. Which among function will be overridden from the function defined in derived class below:

class A
{
int i;
void show()
{
cout&lt;&lt;i;
}
void print()
{
cout &lt;&lt;i;
}
};
class B
{
int j;
void show()
{
cout&lt;&lt;j;
}
};

a) show()
b) print()
c) show() and print()
d) Compile time error
6. How to access the overridden method of base class from the derived class?
a) Using arrow operator
b) Using dot operator
c) Using scope resolution operator
d) Can’t be accessed once overridden
7. The functions to be overridden _____________
a) Must be private in base class
b) Must not be private base class
c) Must be private in both derived and base class
d) Must not be private in both derived and base class
8. Which language doesn’t support the method overriding implicitly?
a) C++
b) C#
c) Java
d) SmallTalk
9. In C# ____________________
a) Non – virtual or static methods can’t be overridden
b) Non – virtual and static methods only can be overridden
c) Overriding is not allowed
d) Overriding must be implemented using C++ code only
10. In Delphi ______________
a) Method overriding is done implicitly
b) Method overriding is not supported
c) Method overriding is done with directive override
d) Method overriding is done with the directive virtually
11. What should be used to call the base class method from the derived class if function
overriding is used in Java?
a) Keyword super
b) Scope resolution
c) Dot operator
d) Function name in parenthesis
12. In Kotlin, the function to be overridden must be ______________
a) Private
b) Open
c) Closed
d) Abstract
13. Abstract functions of a base class _________________
a) Are overridden by the definition in same class
b) Are overridden by the definition in parent class
c) Are not overridden generally
d) Are overridden by the definition in derived class
14. If virtual functions are defined in the base class then _______________
a) It is not necessary for derived classes to override those functions
b) It is necessary for derived classes to override those functions
c) Those functions can never be derived
d) Those functions must be overridden by all the derived classes
15. Which feature of OOP is exhibited by the function overriding?
a) Inheritance
b) Abstraction
c) Polymorphism
d) Encapsulation

Const member function

1. What are the constant member functions?


a) Functions which doesn’t change value of calling object
b) Functions which doesn’t change value of any object inside definition
c) Functions which doesn’t allow modification of any object of class
d) Functions which doesn’t allow modification of argument objects
2. Which keyword must be used to declare a member function as a constant member function?
a) Constant
b) Const
c) FunctionConst
d) Unchanged
3. Which objects can call the const functions?
a) Only const objects
b) Only non-const objects
c) Both const and non-const objects
d) Neither const not non-const objects
4. Non-const functions _______________________
a) Can be called only from non-const object
b) Can be called only from const object
c) Can be called both by const and non-const object
d) Can’t be called with object
5. Which is the correct condition on const member functions?
a) Const member functions can’t call non-const member functions
b) Const member functions can’t call any other function
c) Const member functions can call only the functions which are neither const nor non-const
d) Const member functions can call only data members of call not member functions
6. If a const object calls a non-const member function then ____________________
a) Run time error may get produced
b) Compile time error may get produced
c) Either compile time or run time error is produced
d) The program can’t be compiled
7. Can a constructor function be constant?
a) Yes, always
b) Yes, only if permissions are given
c) No, because objects are not involved
d) No, never
8. A function can have both the const and non-const version in the same program.
a) True
b) False
9. How is it possible to have both const and non-const version of a function?
a) Function overriding
b) Function prototyping
c) Function overloading
d) Function declaring
10. When both the const and non-const version of functions are required?
a) Return value have to be different in const
b) Return value have to be same in const
c) Return values have to be ignored
d) Return values have to be suppressed
11. If a function is to be made const, which is the correct syntax?
a) const functionName(parameters);
b) const returnType functionName(parameters);
c) const functionName(returnType)(Parameters);
d) const (functionName(parameters));
12. Functions which differ in const-ness are considered ______________________
a) To have same signature
b) To have different signature
c) To produce compile time error
d) To produce runtime error
13. If const version of a function when overloading is used, the function ___________________
a) Returns reference to object
b) Returns volatile reference
c) Returns mutable reference
d) Returns const reference
14. Which among the following is recommended for const functions?
a) Const function use should be reduced in a program
b) Const function use should be more in a program
c) Const function use should not matter in a program
d) Const function use should be able to modify the values
15. Use of const member function in a program _________________________
a) Is mandatory, always
b) Is optional, always
c) Is mandatory, if objects are used
d) Is optional, if const objects are used

1. Which is private member functions access scope?


a) Member functions which can only be used within the class
b) Member functions which can used outside the class
c) Member functions which are accessible in derived class
d) Member functions which can’t be accessed inside the class
2. Which among the following is true?
a) The private members can’t be accessed by public members of the class
b) The private members can be accessed by public members of the class
c) The private members can be accessed only by the private members of the class
d) The private members can’t be accessed by the protected members of the class
3. Which member can never be accessed by inherited classes?
a) Private member function
b) Public member function
c) Protected member function
d) All can be accessed
4. Which syntax among the following shows that a member is private in a class?
a) private: functionName(parameters)
b) private(functionName(parameters))
c) private functionName(parameters)
d) private::functionName(parameters)
5. If private member functions are to be declared in C++ then _____________
a) private: <all private members>
b) private <member name>
c) private(private member list)
d) private :- <private members>
6. In java, which rule must be followed?
a) Keyword private preceding list of private member’s
b) Keyword private with a colon before list of private member’s
c) Keyword private with arrow before each private member
d) Keyword private preceding each private member
7. How many private member functions are allowed in a class?
a) Only 1
b) Only 7
c) Only 255
d) As many as required
8. How to access a private member function of a class?
a) Using object of class
b) Using object pointer
c) Using address of member function
d) Using class address
9. Private member functions ____________
a) Can’t be called from enclosing class
b) Can be accessed from enclosing class
c) Can be accessed only if nested class is private
d) Can be accessed only if nested class is public
10. Which function among the following can’t be accessed outside the class in java in same
package?
a) public void show()
b) void show()
c) protected show()
d) static void show()
11. If private members are to be called outside the class, which is a good alternative?
a) Call a public member function which calls private function
b) Call a private member function which calls private function
c) Call a protected member function which calls private function
d) Not possible
12. A private function of a derived class can be accessed by the parent class.
a) True
b) False
13. Which error will be produced if private members are accessed?
a) Can’t access private message
b) Code unreachable
c) Core dumped
d) Bad code
14. Can main() function be made private?
a) Yes, always
b) Yes, if program doesn’t contain any classes
c) No, because main function is user defined
d) No, never
15. If a function in java is declared private then it __________________
a) Can’t access the standard output
b) Can access the standard output
c) Can’t access any output stream
d) Can access only the output streams

1. What are public member functions?


a) Functions accessible outside the class but not in derived class
b) Functions accessible outside the class directly
c) Functions accessible everywhere using object of class
d) Functions that can’t be accessed outside the class
2. Which among the following is true for public member functions?
a) Public member functions doesn’t have a return type
b) Public member functions doesn’t have any security
c) Public member functions are declared outside the class
d) Public member functions can be called using object of class
3. Which type of member functions get inherited in the same specifier in which the inheritance is
done? (If private inheritance is used, those become private and if public used, those become
public)
a) Private member functions
b) Protected member functions
c) Public member functions
d) All member functions
4. Which syntax among the following is correct for public member functions?
a) public::void functionName(parameters)
b) public void functionName(parameters)
c) public(void functionName(parameters))
d) public:-void functionName(Parameters)
5. Which syntax is applicable to declare public member functions in C++?
a) public: <function declaration>
b) public(<function declaration>)
c) public void <function declaration>
d) public::<function declaration
6. In java, which rule among the following is applicable?
a) Keyword public can’t be preceded with all the public members
b) Keyword public must be preceded with all the public members
c) Keyword public must be post mentioned the function declaration
d) Keyword public is not mandatory
7. How many public members are allowed in a class?
a) Only 1
b) At most 7
c) Exactly 3
d) As many as required
8. Which is not a proper way to access public members of a class?
a) Using object pointer with arrow operator
b) Using object of class in main function
c) Using object of class with arrow operator
d) Using object anywhere in the program
9. Which call is correct for public members of a nested class?
a) Can be called from object of enclosing class
b) Can be called within enclosing class only with direct names
c) Direct names should be used for the nested classes
d) Only with help of nested class object pointer
10. Which public function call among the following is correct outside the class, if return type is
void (C++)?
a) object.void functionName(parameters);
b) object.functionName(parameters);
c) object.functionName void (parameters)
d) object.void functionName();
11. If public members are to be restricted from getting inherited from the subclass of the class
containing that function, which alternative is best?
a) Make the function private
b) Use private inheritance
c) Use public inheritance
d) Use protected inheritance
12. A derived class object can access the public members of the base class.
a) True
b) False
13. If a class have a public member function and is called directly in the main function then
___________________________
a) Undeclared function error will be produced
b) Out of memory error is given
c) Program gives warning only
d) Program shut down the computer
14. The function main() must always be public.
a) True
b) False
15. All the public member functions ___________________
a) Can’t access the private members of a class
b) Can’t access the protected members of a class
c) Can access only public members of a class
d) Can access all the member of its class

Static data members

1. Which among the following best defines static variables members?


a) Data which is allocated for each object separately
b) Data which is common to all the objects of a class
c) Data which is common to all the classes
d) Data which is common to a specific method
2. Which keyword should be used to declare static variables?
a) static
b) stat
c) common
d) const
3. Any changes made to static data member from one member function _____________
a) Is reflected to only the corresponding object
b) Is reflected to all the variables in a program
c) Is reflected to all the objects of that class
d) Is constant to that function only
4. Which is the correct syntax for declaring static data member?
a) static mamberName dataType;
b) dataType static memberName;
c) memberName static dataType;
d) static dataType memberName;
5. The static data member ______________________
a) Must be defined inside the class
b) Must be defined outside the class
c) Must be defined in main function
d) Must be defined using constructor
6. The syntax for defining the static data members is __________
a) dataType className :: memberName = value;
b) dataType className : memberName = value;
c) dataType className . memberName = value;
d) dataType className -> memberName =value;
7. If static data members have to be used inside a class, those member functions _______________
a) Must not be static member functions
b) Must not be member functions
c) Must be static member functions
d) Must not be member function of corresponding class
8. The static data member __________________________
a) Can be accessed directly
b) Can be accessed with any public class name
c) Can be accessed with dot operator
d) Can be accessed using class name if not using static member function
9. Which among the following is the correct syntax to access static data member without using
member function?
a) className -> staticDataMember;
b) className :: staticDataMember;
c) className : staticDataMember;
d) className . staticDataMember;
10. Which data members among the following are static by default?
a) extern
b) integer
c) const
d) void
11. What is the output of the following program?

class Test
{
private: static int x;
public: static void fun()
{
cout &lt;&lt; ++x &lt;&lt; “ ”;
}
};
int Test :: x =20;
void main()
{
Test x;
x.fun();
x.fun();
}

a) 20 22
b) 20 21
c) 21 22
d) 22 23
12. Whenever any static data member is declared in a class ______________________
a) Only one copy of the data is created
b) New copy for each object is created
c) New memory location is allocated with each object
d) Only one object uses the static data
13. If object of class are created, then the static data members can be accessed ____________
a) Using dot operator
b) Using arrow operator
c) Using colon
d) Using dot or arrow operator
14. What will be the output of the following program?

class Test
{
public: Test()
{
cout &lt;&lt; "Test's Constructor is Called " &lt;&lt; endl;
}
};

class Result
{
static Test a;
public:
Result()
{
cout &lt;&lt; "Result's Constructor is Called " &lt;&lt; endl;
}
};

void main()
{
Result b;
}

a) Test’s Constructor is Called


b) Result’s Constructor is Called
c) Result’s Constructor Called Test’s Constructor is Called
d) Test’s Constructor Called Result’s Constructor is Called
15. Which among the following is wrong syntax related to static data members?
a) className :: staticDataMember;
b) dataType className :: memberName =value;
c) static dataType memberName;
d) className : dataType -> memberName;

1. Which among the following is correct definition for static member functions?
a) Functions created to allocate constant values to each object
b) Functions made to maintain single copy of member functions for all objects
c) Functions created to define the static members
d) Functions made to manipulate static programs
2. The static member functions __________________
a) Have access to all the members of a class
b) Have access to only constant members of a class
c) Have access to only the static members of a class
d) Have direct access to all other class members also
3. The static member functions ____________________
a) Can be called using class name
b) Can be called using program name
c) Can be called directly
d) Can’t be called outside the function
4. Which is correct syntax to access the static member functions with class name?
a) className . functionName;
b) className -> functionName;
c) className : functionName;
d) className :: functionName;
5. Which among the following is not applicable for the static member functions?
a) Variable pointers
b) void pointers
c) this pointer
d) Function pointers
6. Which among the following is true?
a) Static member functions can’t be virtual
b) Static member functions can be virtual
c) Static member functions can be declared virtual if it is pure virtual class
d) Static member functions can be used as virtual in Java
7. The static members are ______________________
a) Created with each new object
b) Created twice in a program
c) Created as many times a class is used
d) Created and initialized only once
8. Which among the following is true?
a) Static member functions can be overloaded
b) Static member functions can’t be overloaded
c) Static member functions can be overloaded using derived classes
d) Static member functions are implicitly overloaded
9. The static member functions _______________
a) Can’t be declared const
b) Can’t be declared volatile
c) Can’t be declared const or volatile
d) Can’t be declared const, volatile or const volatile
10. Which keyword should be used to declare the static member functions?
a) static
b) stat
c) const
11. The keyword static is used _______________
a) With declaration inside class and with definition outside the class
b) With declaration inside class and not with definition outside the class
c) With declaration and definition wherever done
d) With each call to the member function
12. Which among the following can’t be used to access the members in any way?
a) Scope resolution
b) Arrow operator
c) Single colon
d) Dot operator
13. We can use the static member functions and static data member __________________
a) Even if class object is not created
b) Even if class is not defined
c) Even if class doesn’t contain any static member
d) Even if class doesn’t have complete definition
14. The static data member _________________
a) Can be mutable
b) Can’t be mutable
c) Can’t be integer
d) Can’t be characters
15. If static data member are made inline, ______________
a) Those should be initialized outside the class
b) Those can’t be initialized with the class
c) Those can be initialized within the class
d) Those can’t be used by class members

String class

1. Which is a true statement for object of String class?


a) Object are immutable
b) Object are mutable
c) Object are created only once
d) Object can’t be created
2. How to declare an object of class String?
a) String object_Name = value;
b) String object_name = new;
c) String object_name= new value;
d) String object_name= value new;
3. What does function length do in String class?
a) Returns length of string including null character
b) Returns length of string excluding null character
c) Returns length of substring
d) Returns size of string in bytes
4. Which is the function to get the character present at a particular index in the string?
a) char charAt(index);
b) char charIn(StringName);
c) char charAt(StringName);
d) char charIn(index);
5. If only one parameter is passed to substring function then __________________
a) It returns the character at the specified position
b) It returns the string of length 1 from the specified index
c) It returns the string from specified index till the end
d) It returns the string from starting of string till the specified index
6. If two index are given as argument to substring function then ___________________
a) String of length equal to sum of two arguments is returned
b) String starting from first index and of length equal to send argument
c) String starting from first index and of length equal to sum of two arguments
d) String starting from first index and ending at second index position
7. String class have a concat() function that is used to _____________________
a) Replace old string by new string
b) Add two strings
c) Append one string at end of another string
d) Remove a string from end of one string
8. The function lastIndexOf() is used to ___________________
a) Get the index of last occurrence of specified character in argument
b) Get the index of first occurrence of specified character in argument
c) Get the index of last occurrence of first character in string
d) Get the index of last occurrence of last character of string
9. Function equals() is _______________ and equalIgnoreCase() is _________________
a) Case Insensitive, case insensitive
b) Case sensitive, Case insensitive
c) Case sensitive, case sensitive
d) Case insensitive, case sensitive
10. The compareTo() function is used to ________________
a) Compare strings value to string object
b) Compare string value to string value
c) Compare string object to another string object
d) Compare string object to another string value
11. String class provides function toUpper() to _____________________
a) Convert first character to uppercase
b) Convert last character to uppercase
c) Convert the whole string characters to uppercase
d) Convert uppercase to lower and lower to uppercases
12. String trim() function is used to _______________________
a) Remove all the white spaces from the string
b) Remove white space from start of string
c) Remove white space at end of string
d) Remove white space from both the ends of string
13. Function replace() accepts _____________ arguments.
a) 1
b) 2
c) 3
d) 4
14. If two arguments are passed to the indexOf() function then ___________________
a) Second argument indicates the occurrence number of specified character from starting
b) Second argument indicates the occurrence number of specified character from end
c) Second argument indicates the index of the character in first argument
d) Second argument indicates the index of the character from the last of the string
15. The string class deals with string of only character type.
a) True
b) False

New operator

1. What is the new operator?


a) Allocates memory for an object or array
b) Allocates memory for an object or array and returns a particular pointer
c) Used as return type when an object is created
d) Used to declare any new thing in a program
2. Microsoft C++ Components extensions support new keyword to _____________
a) Modify a vtable
b) Replace a vtable slot entry
c) Add new vtable slot entries
d) Rearrange vtable slot entries
3. What happens when new fails?
a) Returns zero always
b) Throws an exception always
c) Either throws an exception or returns zero
d) Terminates the program
4. If new throws an error, which function can be called to write a custom exception handler?
a) _set_handler
b) _new_handler
c) _handler_setter
d) _set_new_handler
5. In C++, if new operator is used, when is the constructor called?
a) Before the allocation of memory
b) After the allocation of memory
c) Constructor is called to allocate memory
d) Depends on code
6. Which among the following is correct syntax to declare a 2D array using new operator?
a) char (*pchar)[10] = new char[][10];
b) char (pchar) = new char[][10];
c) char (*char) = new char[10][];
d) char (*char)[][10]= new char;
7. For declaring data by using new operator ____________________
a) Type name can’t contain const
b) Type name can’t contain volatile
c) Type name can’t contain class declarations
d) Type name can’t contain const, volatile, class declaration or enumerations
8. The new operator _____________
a) Can allocate reference types too
b) Doesn’t allocate reference types
c) Can allocate reference to objects
d) Doesn’t allocate any data
9. Which among the following is true?
a) New operator can’t allocate functions but pointer to functions can be allocated
b) New operator can allocate functions as well as pointer to functions
c) New operator can allocate any type of functions
d) New operator is not applicable with functions allocation
10. Which among the following is added in grammar of new operator?
a) Finalize
b) Arg
c) Initializer
d) Allocator
11. Initializers __________________
a) Are used for specifying arrays
b) Are used to defined multidimensional arrays
c) Can’t be specified for arrays
d) Can’t be specified for any data
12. The objects allocated using new operator ________________
a) Are destroyed when they go out of scope
b) Are not destroyed even if they go out of scope
c) Are destroyed anytime
d) Are not destroyed throughout the program execution
13. The new operator _________________
a) Invokes function operator new
b) Doesn’t invoke function operator new
c) Invokes function operator only if required
d) Can’t invoke function operator new implicitly
14. If a new operator is defined for a class and still global new operator have to be used, which
operator should be used with the keyword new?
a) Colon
b) Arrow
c) Dot
d) Scope resolution
15. How does compiler convert “::operator new” implicitly?
a) ::operator new( sizeof( type ) )
b) ::operator new( sizeof( ) )
c) new operator :: type sizeof( type )
d) new sizeof( type ) operator

Delete operator

1. What is a delete operator?


a) Deallocates a block of memory
b) Deallocates whole program memory
c) Deallocates only primitive data memory
d) Deallocates all the data reserved for a class
2. If an object is allocated using new operator ____________
a) It should be deleted using delete operator
b) It can’t be deleted using delete operator
c) It may or may not be deleted using delete operator
d) The delete operator is not applicable
3. Does delete return any value?
a) Yes, positive value
b) Yes, negative value
c) Yes, zero value
d) No
4. Which type of value has resulted from the delete operator?
a) void
b) void pointer
c) null pointer
d) null
5. If delete is used to delete an object which was not allocated using new _______________
a) Then out of memory error arises
b) Then unreachable code error arises
c) Then unpredictable errors may arise
d) Then undefined variable error arises
6. Delete operator _________________
a) Can be used on pointers with null value
b) Can be used on pointers with void value
c) Can be used on pointer with value 0
d) Can be used on pointer with any value
7. When delete operator is used ___________________ (If object has a destructor)
a) Object destructor is called after deallocation
b) Object destructor is called before deallocation
c) Object destructor is not used
d) Object destructor can be called anytime during destruction
8. If delete is applied to an object whose l-value is modifiable, then _______________ after the object
is deleted.
a) Its value is defined as null
b) Its value is defined as void
c) Its value is defined as 0
d) Its value is undefined
9. How many variants of delete operator are available?
a) Only 1
b) Only 2
c) Only 3
d) Only 4
10. Which is the correct syntax to delete a single object?
a) delete *objectName;
b) objectName delete;
c) delete objectName;
d) objectName *delete;
11. Which is the correct syntax to delete an array of objects?
a) delete [] objectName;
b) delete * objectName;
c) objectName[] delete;
d) delete objectName[];
12. Which cases among the following produces the undefined result?
a) delete [] on an independent object
b) delete on an object array
c) delete [] on an object and delete on object array
d) Undefined result is never produced
13. The delete operator __________________
a) Invokes function operator delete
b) Invokes function defined by user to delete
c) Invokes function defined in global scope to delete object
d) Doesn’t invoke any function
14. For objects that are not of class type ______________
a) Global delete operator is invoked
b) Local delete operator is invoked
c) Global user defined function is invoked
d) Local function to delete object is called
15. The delete operator __________________________
a) Can be defined for each class
b) Can’t be defined for each class
c) Can be defined globally only
d) Can’t be defined in a program explicitly

Automatic variable

1. What are automatic variables?


a) Global variables
b) Implicit/temporary variables
c) Local variables
d) System variables
2. The memory for automatic variables ___________________
a) Have to be allocated and deallocated explicitly
b) Are allocated and deallocated automatically
c) Is never actually allocated
d) Are never safe
3. Scope of an automatic variable _______________
a) Is actually the whole program
b) Is actually never fixed
c) Is always equal to the whole program execution
d) Is actually function or block in which it is defined
4. Which among the following is true for automatic variables in general?
a) Automatic variables are invisible to called function
b) Automatic variables are always visible to the called function
c) Automatic variables can’t interact with the called function
d) Automatic variables can’t be variable
5. If an automatic variable is created and then a function is called then ________________
a) The automatic variable created gets destroyed
b) The automatic variable doesn’t get destroyed
c) The automatic variable may or may not get destroyed
d) The automatic variable can’t be used in this case
6. Where are the automatic variables stored if another function is called in between the execution
of the program?
a) Heap
b) Queue
c) Stack
d) Temp variable
7. The static variables of a function ________________
a) Are also automatic variables
b) Are not automatic variables
c) Are made automatic by default
d) Can be made automatic explicitly
8. All variables declared within a block ____________________
a) Are not always automatic
b) Can be made non-automatic
c) Are static by default
d) Are automatic by default
9. What values does uninitialized automatic variables contain?
a) Null value
b) Void value
c) Undefined/Garbage
d) Zero value
10. Constructor of automatic variables is called ____________________
a) When execution reaches the place of declaration of automatic variables
b) When the program is compiled
c) When the execution is just started
d) Just before the execution of the program
11. Does java contain auto or register keywords?
a) Yes, for declaring every type of variable
b) Yes, only to declare cache registers
c) No, because java doesn’t support automatic variables
d) No, java supports local variable concept
12. The automatic variables _________________________
a) Must be declared after its use
b) Must be declared before using
c) Must be declared, can be anytime
d) Must not be initialized
13. Which error is produced if the automatic variables are used without declaration?
a) Undefined symbol
b) Memory error
c) Type mismatch
d) Statement missing
14. In Perl, using which operator are the local variables created?
a) Dot
b) Arrow
c) Scope resolution
d) my
15. How are automatic variables different from the instance variables?
a) Automatic variables are initialized automatically but instances are not
b) Automatic variables are given zero values initially and not instances
c) Instance variables have to be initialized explicitly and automatic implicitly
d) Instance variables are initialized implicitly while automatic are not

Extern variable

1. What is extern variable?


a) Variables to be used that are declared in another object file
b) Variables to be used that are declared in another source file
c) Variables to be used that are declared in another executable file
d) Variables to be used that are declared in another program
2. Which among the following is a correct statement for variables?
a) Variable can be declared many times
b) Variable can be declared only one time
c) Variable declaration can’t be done more than ones
d) Variable declaration is always done more than one time
3. Which among the following is true for the variables?
a) Variable can be defined only once
b) Variable can be defined any number of times
c) Variable must be defined more than one time
d) Variable can be defined in different files
4. To use extern variable _____________________
a) The source file must not be included in the new file code
b) The source file itself must be used for a new program
c) The source file must be included in the new file
d) The source file doesn’t matter for extern variables
5. What does a header file contain for an extern variable?
a) Only declaration of variables
b) Only definition of variables
c) Both declaration and definition of variables
d) Neither declaration nor definition
6. Which condition is true if the extern variable is used in a file?
a) All the header files declare it
b) Only few required files declare it
c) All header files declared it if required
d) Only one header file should declare it
7. Whenever a function is declared in a program _____________________
a) extern can be used only in some special cases
b) extern can’t be used
c) function is extern by default
d) it can’t be made extern
8. Even if a variable is not declared as extern, it is extern by default.
a) True
b) False
9. Which of the following results in the allocation of memory for the extern variables?
a) Declaration
b) Definition
c) Including file
d) Memory is not allocated for extern variables
10. Which is the correct syntax for extern variable declaration?
a) extern data_type variable_name;
b) extern variable_name;
c) data_type variable_name extern;
d) extern (data_type)variable_name;
11. Which is the correct syntax for extern function declaration?
a) extern function_name(argument_list);
b) extern return_type function_name(argument_list);
c) extern (return_type)function_name(argument_list);
d) return_type extern function_name(argument_list);
12. What will be the output of the program?
extern int var;
int main(void)
{
var = 10;
var++;
cout<<var;
}

a) 10
b) 11
c) Run time error
d) Compile time error
13. If the definition is given in the header file that we include then ________________
a) The program can run successfully
b) Also the program should define the extern variable
c) The extern variable must contain two definitions
d) Extern variable can’t be used in the program
14. If extern variable is initialized with the declaration then _______________________
a) Also the header file with definition is required
b) The header file with definition must be included
c) There is no need to include any other header file for definition
d) The extern variable produces compile time error
15. Why are functions extern by default?
a) Because functions are always private
b) Because those are not visible throughout the program
c) Because those can’t be accessed in all parts of the program
d) Because those are visible throughout the program

Constructor overloading

1. Which among the following is true for constructors overloading?


a) Constructors can’t be overloaded
b) Constructors can be overloaded using different signatures
c) Constructors can be overloaded with same signatures
d) Constructors can be overloaded with different return types
2. If a constructors should be capable of creating objects without argument and with arguments,
which is a good alternative for this purpose?
a) Use zero argument constructor
b) Use constructor with one parameter
c) Use constructor with all default arguments
d) Use default constructor
3. The Constructors with all the default arguments are similar as default constructors.
a) True
b) False
4. Which among the following is true?
a) The constructors overloading can be done by using different names
b) The constructors overloading can be done by using different return types
c) The constructors can be overloaded by using only one argument
d) The constructors must have the same name as that of class
5. Which among the following can be used in place of default constructor?
a) constructorName(int x, int y=0)
b) constructorName(int x=0, int y=0)
c) constructorName(int x=0, int y)
d) constructorName(int x, int y)
6. Can a class have more than one function with all the default arguments?
a) Yes, always
b) Yes, if argument list is different
c) No, because constructors overloading doesn’t depend on argument list
d) No, never
7. Which is the correct syntax for using default arguments with the constructor?
a) default constructorName(default int x=0)
b) constructorName(default int x=0)
c) constructorName(int x=0)
d) constructorName()
8. How many parameters must be passed if only the following prototype is given to a constructor?
Prototype: className(int x, int y, int z=0);
a) 1
b) 2
c) 3
d) Compile time error
9. If the constructors are overloaded by using the default arguments, which problem may arise?
a) The constructors might have all the same arguments except the default arguments
b) The constructors might have same return type
c) The constructors might have same number of arguments
d) The constructors can’t be overloaded with respect to default arguments
10. Which among the following is true?
a) More than one constructors with all default arguments is allowed
b) More than one constructors with all default arguments can be defined outside the class
c) More than one constructors can be used with same argument list
d) More than one constructors with all default arguments can’t exist in same class
11. Which constructor among the following will be called if a call is made like className(5,’a’);?
a) className(int x=5,char c=’a’);
b) int className(int x, char c, char d);
c) className(int x, char c, int y);
d) char className(char c,int x);
12. Which constructor definition will produce a compile time error?
a) className(int x=0);
b) className(char c);
c) className(int x=0,char c);
d) className(char c,int x=0);
13. If there is a constructor with all the default arguments and arguments are not passed then
_________________
a) The default values given will not be used
b) Then all the null values will be used
c) Then all the default values given will be used
d) Then compiler will produce an error
14. Which is the correct statement for default constructors?
a) The constructors with all the default arguments
b) The constructors with all the null and zero values
c) The constructors which can’t be defined by programmer
d) The constructors with zero arguments
15. Which is a good alternative instead of having one zero argument constructor and one single
argument constructor with default argument?
a) No constructor defined
b) One default value constructor
c) Defining the default constructor
d) Using one constructor with two arguments

Passing object

1. Passing object to a function _______________


a) Can be done only in one way
b) Can be done in more than one ways
c) Is not possible
d) Is not possible in OOP
2. The object ________________
a) Can be passed by reference
b) Can be passed by value
c) Can be passed by reference or value
d) Can be passed with reference
3. Which symbol should be used to pass the object by reference in C++?
a) &
b) @
c) $
d) $ or &
4. If object is passed by value ______________
a) Copy constructor is used to copy the values into another object in the function
b) Copy constructor is used to copy the values into temporary object
c) Reference to the object is used to access the values of the object
d) Reference to the object is used to created new object in its place
5. Pass by reference of an object to a function _______________
a) Affects the object in called function only
b) Affects the object in prototype only
c) Affects the object in caller function
d) Affects the object only if mentioned with & symbol with every call
6. Copy constructor definition requires __________________
a) Object to be passed by value
b) Object not to be passed to it
c) Object to be passed by reference
d) Object to be passed with each data member value
7. What is the type of object that should be specified in the argument list?
a) Function name
b) Object name itself
c) Caller function name
d) Class name of object
8. If an object is passed by value, _________________
a) Temporary object is used in the function
b) Local object in the function is used
c) Only the data member values are used
d) The values are accessible from the original object
9. Can data members be passed to a function using the object?
a) Yes, it can be passed only inside class functions
b) Yes, only if the data members are public and are being passed to a function outside the class
c) No, can’t be passed outside the class
d) No, can’t be done
10. What exactly is passed when an object is passed by reference?
a) The original object name
b) The original object class name
c) The exact address of the object in memory
d) The exact address of data members
11. If the object is not to be passed to any function but the values of the object have to be used
then?
a) The data members should be passed separately
b) The data members and member functions have to be passed separately
c) The values should be present in other variables
d) The object must be passed
12. Which among the following is true?
a) More than one object can’t be passed to a function
b) Any number of objects can be passed to a function
c) Objects can’t be passed, only data member values can be passed
d) Objects should be passed only if those are public in class
13. What will be the output if all necessary code is included (Header files and main function)?

void test (Object &y)


{
y = "It is a string";
}
void main()
{
Object x = null;
test (x);
System.out.println (x);
}

a) Run time error


b) Compile time error
c) Null
d) It is a string
14. In which type is new memory location will be allocated?
a) Only in pass by reference
b) Only in pass by value
c) Both in pass by reference and value
d) Depends on the code
15. Pass by reference and pass by value can’t be done simultaneously in a single function
argument list.
a) True
b) False

1. In which of the following way(s) can the object be returned from a function?
a) Can only be returned by value
b) Can only be returned by reference
c) Can be returned either by value or reference
d) Can neither be returned by value nor by reference
2. Whenever an object is returned by value ____________________
a) A temporary object is created
b) Temporary object is not created
c) Temporary object may or may not be created
d) New permanent object is created
3. Where the temporary objects (created while return by value) are created?
a) Outside the function scope
b) Within the function
c) Inside the main function
d) Inside the calling function
4. Which is the correct syntax for returning an object by value?
a) void functionName ( ){ }
b) object functionName( ) { }
c) class object functionName( ) { }
d) ClassName functionName ( ){ }
5. Which is the correct syntax for defining a function which passes an object by reference?
a) className& functionName ( )
b) className* functionName( )
c) className-> functionName( )
d) &className functionName()
6. If an object is declared inside the function then ____________________ outside the function.
a) It can be returned by reference
b) It can’t be returned by reference
c) It can be returned by address
d) It can’t be returned at all
7. How many independent objects can be returned at same time from a function?
a) 1
b) 2
c) 3
d) 4
8. Which error will be produced if a local object is returned by reference outside a function?
a) Out of memory error
b) Run time error
c) Compile time error
d) No error
9. If object is passed by reference ____________________
a) Temporary object is created
b) Temporary object is created inside the function
c) Temporary object is created for few seconds
d) Temporary object is not created
10. Which among the following is correct?
a) Individual data members can’t be returned
b) Individual data members can be returned
c) Individual member functions can be returned from another function
d) Individual data members can only be passed by reference
11. Can we return an array of objects?
a) Yes, always
b) Ye, only if objects are having same values
c) No, because objects contain many other values
d) No, because objects are single entity
12. If an object is passed by reference to a function then it must be returned by reference.
a) True
b) False
13. Which among the following is true?
a) Two objects can point to the same memory location
b) Two objects can never point to the same memory location
c) Objects not allowed to point at a location already occupied
d) Objects can’t point to any address
14. If an object is being returned by value then __________________________
a) Its member values are made constant
b) Its member values have to be copied individually
c) Its member values are not used
d) Its member values are copied using copy constructor
15. Why temporary object is not created in return by reference?
a) Because compiler can’t create temporary objects
b) Because the temporary object is created within the function
c) Because return by reference just make the objects points to values memory location
d) Because return by reference just make the object point to null

1. When value of an object is assigned to another object ________________


a) It becomes invalid statement
b) Its values gets copied into another object
c) Its values gets address of the existing values
d) The compiler doesn’t execute that statement
2. If an object is created and another object is assigned to it, then ________________
a) Copy constructor is called to copy the values
b) Object is copied directly to the object
c) Reference to another object is created
d) The new object is initialized to null values
3. How the argument passed to a function get initialized?
a) Assigned using copy constructor at time of passing
b) Copied directly
c) Uses addresses always
d) Doesn’t get initialized
4. Predict the output of the program.

class A
{
public int i;
};
void main()
{
A x;
A y=x;
x.i=10;
y.i=20;
y.i++;
y.i=20;
cout&l;&lt;tx.i;
}

a) 10
b) 20
c) 21
d) 0
5. If programmer doesn’t define any copy assignment operator then ____________________
a) Compiler gives an error
b) Program fails at run time
c) Compiler gives an implicit definition
d) Compiler can’t copy the member values
6. Declaring a copy constructor doesn’t suppresses the compiler generated copy assignment
operator.
a) True
b) False
7. In copy constructor definition, if non const values are accepted only ________
a) Only const objects will be accepted
b) Only non – const objects are accepted
c) Only const members will not get copied
d) Compiler generates an error
8. How many objects can be assigned to a single address?
a) Only 1
b) At most 7
c) At most 3
d) As many as required
9. Use of assignment operator ____________________
a) Changes its use, when used at declaration and in normal assignment
b) Doesn’t changes its use, whatever the syntax might be
c) Assignment takes place in declaration and assignment syntax
d) Doesn’t work in normal syntax, but only with declaration
10. If more than one object refer to the same address, any changes made __________
a) Can be made visible to specific objects
b) Will be specific to one object only
c) From any object will be visible in all
d) Doesn’t changes the values of all objects
11. How to make more than one object refer to the same object?
a) Initialize it to null
b) Initialize the object with another at declaration
c) Use constructor to create new object
d) Assign the address directly
12. We can assign ______________________
a) Value of one reference variable to another
b) Value of any object to another
c) Value of any type to any object
d) Value of non – reference to another reference
13. Assigning reference to an object _________________
a) Will create another copy of the object
b) Will create two different copies of the object
c) Will not create any other copy of the object
d) Will not refer to the object
14. Which among the following is true?
a) We can use direct assignment for any object
b) We can use direct assignment only for different class objects
c) We must not use direct assignment
d) We can use direct assignment to same class objects
15. Assigning objects takes place while passing the arguments.
a) True
b) False

1. Which language among the following doesn’t allow pointers?


a) C++
b) Java
c) Pascal
d) C
2. Which is correct syntax for declaring pointer to object?
a) className* objectName;
b) className objectName;
c) *className objectName;
d) className objectName();
3. Which operator should be used to access the members of the class using object pointer?
a) Dot operator
b) Colon to the member
c) Scope resolution operator
d) Arrow operator
4. How does compiler decide the intended object to be used, if more than one object are used?
a) Using object name
b) Using an integer pointer
c) Using this pointer
d) Using void pointer
5. If pointer to an object is declared __________
a) It can store any type of address
b) It can store only void addresses
c) It can only store address of integer type
d) It can only store object address of class type specified
6. What is the size of an object pointer?
a) Equal to size of any usual pointer
b) Equal to size of sum of all the members of object
c) Equal to size of maximum sized member of object
d) Equal to size of void
7. A pointer _________________
a) Can point to only one object at a time
b) Can point to more than one objects at a time
c) Can point to only 2 objects at a time
d) Can point to whole class objects at a time
8. Pointer to a base class can be initialized with the address of derived class, because of _________
a) derived-to-base implicit conversion for pointers
b) base-to-derived implicit conversion for pointers
c) base-to-base implicit conversion for pointers
d) derived-to-derived implicit conversion for pointers
9. Can pointers to object access the private members of the class?
a) Yes, always
b) Yes, only if it is only pointer to object
c) No, because objects can be referenced from another objects too
d) No, never
10. Is name of an array of objects is also a pointer to object?
a) Yes, always
b) Yes, in few cases
c) No, because it represents more than one object
d) No, never
11. Which among the following is true?
a) The pointer to object can hold address only
b) The pointer can hold value of any type
c) The pointer can hold only void reference
d) The pointer can’t hold any value
12. Which is the correct syntax to call a member function using pointer?
a) pointer->function()
b) pointer.function()
c) pointer::function()
d) pointer:function()
13. If a pointer to an object is created and the object gets deleted without using the pointer then
__________
a) It becomes void pointer
b) It becomes dangling pointer
c) It becomes null pointer
d) It becomes zero pointer
14. How can the address stored in the pointer be retrieved?
a) Using * symbol
b) Using $ symbol
c) Using & symbol
d) Using @ symbol
15. What should be done to prevent changes that may be made to the values pointed by the
pointer?
a) Usual pointer can’t change the values pointed
b) Pointer should be made virtual
c) Pointer should be made anonymous
d) Pointer should be made const
16. References to object are same as pointers of object.
a) True
b) False

1. Which is the pointer which denotes the object calling the member function?
a) Variable pointer
b) This pointer
c) Null pointer
d) Zero pointer
2. Which among the following is true?
a) this pointer is passed implicitly when member functions are called
b) this pointer is passed explicitly when member functions are called
c) this pointer is passed with help of pointer member functions are called
d) this pointer is passed with help of void pointer member functions are called
3. The this pointer is accessible __________________
a) Within all the member functions of the class
b) Only within functions returning void
c) Only within non-static functions
d) Within the member functions with zero arguments
4. An object’s this pointer _____________________
a) Isn’t part of class
b) Isn’t part of program
c) Isn’t part of compiler
d) Isn’t part of object itself
5. The result of sizeof() function __________________
a) Includes space reserved for this pointer
b) Includes space taken up by the address pointer by this pointer
c) Doesn’t include the space taken by this pointer
d) Doesn’t include space for any data member
6. Whenever non-static member functions are called _______________
a) Address of the object is passed implicitly as an argument
b) Address of the object is passed explicitly as an argument
c) Address is specified globally so that the address is not used again
d) Address is specified as return type of the function
7. Which is the correct interpretation of the member function call from an object,
object.function(parameter);
a) object.function(&this, parameter)
b) object(&function,parameter)
c) function(&object,&parameter)
d) function(&object,parameter)
8. The address of the object _________________
a) Can’t be accessed from inside the function
b) Can’t be accessed in the program
c) Is available inside the member function using this pointer
d) Can be accessed using the object name inside the member function
9. Which among the following is true?
a) This pointer can be used to guard against any kind of reference
b) This pointer can be used to guard against self-reference
c) This pointer can be used to guard from other pointers
d) This pointer can be used to guard from parameter referencing
10. Which syntax doesn’t execute/is false when executed?
a) if(&object != this)
b) if(&function !=object)
c) this.if(!this)
d) this.function(!this)
11. The this pointers _____________________
a) Are modifiable
b) Can be assigned any value
c) Are made variables
d) Are non-modifiable
12. Earlier implementations of C++ ___________________
a) Never allowed assignment to this pointer
b) Allowed no assignment to this pointer
c) Allowed assignments to this pointer
d) Never allowed assignment to any pointer
13. This pointer can be used directly to ___________
a) To manipulate self-referential data structures
b) To manipulate any reference to pointers to member functions
c) To manipulate class references
d) To manipulate and disable any use of pointers
14. Which among the following is/are type(s) of this pointer?
a) const
b) volatile
c) const or volatile
d) int
15. Which is the correct syntax for declaring the type of this in a member function?
a) classType [cv-qualifier-list] *const this;
b) classType const[cv-qualifier-list] *this;
c) [cv-qualifier-list]*const classType this;
d) [cv-qualifier-list] classType *const this;

1. What are default arguments?


a) Arguments which are not mandatory to be passed
b) Arguments with default value that aren’t mandatory to be passed
c) Arguments which are not passed to functions
d) Arguments which always take same data value
2. Which is the correct condition for the default arguments?
a) Those must be declared as last arguments in argument list
b) Those must be declared first in the argument list
c) Those can be defined anywhere in the argument list
d) Those are declared inside the function definition
3. If a member function have to be made both zero argument and parameterized constructor,
which among the following can be the best option?
a) Two normal and one default argument
b) At least one default argument
c) Exactly one default argument
d) Make all the arguments default
4. Which among the following function can be called without arguments?
a) void add(int x, int y=0)
b) void add(int=0)
c) void add(int x=0, int y=0)
d) void add(char c)
5. If a function have all the default arguments but still some values are passed to the function
then ______________
a) The function will use the values passed to it
b) The function will use the default values as those are local
c) The function can use any value whichever is higher
d) The function will choose the minimum values
6. Which among the following is correct?
a) void test(int x=0, int y, int z=0)
b) void test(int x=0, int=0)
c) void test(int x, int y=0)
d) void test(int x=’c, int y)
7. What function will be called with the independent syntax “test(5,6,7);”?
a) void test(int x, int y)
b) void test(int x=0, int y, int z)
c) int test(int x=0, y=0, z=0)
d) void test(int x, int y, int z=0)
8. Which among the following is a wrong call to the function void test(int x, int y=0, int z=0)?
a) test(5,6,7);
b) test(5);
c) test();
d) test(5,6);
9. Default arguments are _________________________
a) Only allowed in the parameter list of the function declaration
b) Only allowed in the return type of the function declaration
c) Only allowed with the class name definition
d) Only allowed with the integer type values
10. Which among the following is false for default arguments?
a) Those are not allowed with a declaration of pointer to functions
b) Those are not allowed with the reference to functions
c) Those are not allowed with the typedef declarations
d) Those are allowed with pointer and reference to function declaration
11. The non-template functions can be added with default arguments to already declared
functions ____________________
a) If and only if the function is declared again in the same scope
b) If and only if the function is declared only once in the same scope
c) If and only if the function is declared in different scope
d) If and only if the function is declared twice in the program
12. The using declaration __________
a) Doesn’t carry over the default values
b) Carries over the known default arguments
c) Carries over only the normal arguments
d) Carries over only few default arguments
13. The names given to the default arguments are only looked up and ________________ and are
bound during declaration.
a) Checked for availability
b) Checked for random access
c) Checked for accessibility
d) Checked for feasibility
14. The default argument get bound during declaration ________________
a) And are never executed
b) And are executed simultaneously
c) But are executed only if priority is given
d) But are executed during function call
15. The virtual function overrides ____________
a) Do not acquire base class declaration of default arguments
b) Do acquire base class declaration of default arguments
c) Do not link with the default arguments of base class
d) Do link with the default argument but only of derived classes

You might also like