Oops Viva Questions
Oops Viva Questions
Oops Viva Questions
UNIT-1
1. What is OOP?
Answer:- POPS follows top down approach while OOPS follows bottom up approach.
In POP program is divided into smaller parts called function, while in oops program is divided
into smaller parts called objects.
I.) Objects:- An object is defined as an entity that contain data and its related function.
II.) Class:- A class is defined as a collection of objects with same type of data and functions.
III.) Data abstraction:- Abstraction means displaying only essential information and hiding
the details. Data abstraction refers to providing only essential information about the
data to the outside world, hiding the background details or implementation.
IV.) Data encapsulation:- In Object Oriented Programming, Encapsulation is defined as
binding together the data and the functions that manipulates them.
V.) Inheritance:- It is defined as sharing of attributes and functions among classes based on
a hierarchical or sequential relationship.
VI.) Polymorphism:- A function is said to be polymorphic if it is applied to many different
classes with different operation.
VII.) Dynamic Binding:- Binding is defined as the connection between the function call and its
corresponding program code to be executed. In dynamic binding, the code to be
executed in response to function call is decided at runtime.
VIII.) Message passing:- It is process of locating and executing a function in response to a
message.
4. Name some benefits of OOP.
5. What is method?
Answer:- A data type is used to indicate the type of data value stored in a variable.
Answer:- These data types are built-in or predefined data types and can be used directly by the
user to declare variables. Example:- Integer, float, character, Boolean, etc
8. What is derived data types?
Answer:- The data-types that are derived from the primitive or built-in data types. Example:-
array, pointer, etc
Answer:- The data types defined by the user are known as the user-defined data types.
Example:- Structure, union, class, typedef,etc
Answer:- Integer type, Floating point type, Character type, String type.
Answer:- Type conversion or typecasting of variables refers to changing a variable of one data
type into another.
Answer:- In variables:- This is used to access global variables if same variables are declared as
local and global.
In methods:- To define a member function outside the class definition we have to use the scope
resolution :: operator along with class name and function name.
Answer:- Access specifier or access modifiers are the labels that specify type of access given to
members of a class. These are used for data hiding. These are also called as visibility modes.
Answer:- An argument is referred to the values that are passed within a function when the
function is called. They are also called Actual Parameters
Answer:- The values which are defined at the time of the function prototype or definition of the
function are called as parameters. They are also called Formal Parameters.
22. What is UML?
Answer:- The Unified Modeling Language (UML) is the primary modeling language used to
analyze, specify, and design software systems. UML diagrams can be classified into two groups:
structure diagrams and behavior diagrams.
Answer:- These diagrams are used to show the static structure of elements in the system.
Answer:- Those digram in which the dynamic behavioral semantics of a problem or its
implementation is depicited
Answer:- Package diagrams are structural diagrams used to show the organization and
arrangement of various model elements in the form of packages.
Answer:- A class diagram is a view of the static structure of a system. It contains Packages,
classes, interfaces, and relationships.
Answer:- Component diagrams are used in modeling the physical aspects of object-oriented
systems that are used for visualizing, specifying, and documenting component-based systems.
Answer:- A deployment diagram is a UML diagram type that shows the execution architecture of
a system, including nodes such as hardware or software execution environments, and the
middleware connecting them. Deployment diagrams are typically used to visualize the physical
hardware and software of a system.
Answer:- A UML use case diagram is the primary form of system/software requirements for a
new software program underdeveloped. Use cases specify the expected behavior (what), and
not the exact method of making it happen (how).
32. What is Activity diagram?
Answer:- An activity diagram is a behavioral diagram that portrays the control flow from a start
point to a finish point showing the various decision paths that exist while the activity is being
executed.
Answer:- It shows the implementation phase of systems development, such as the source code
structure and the run-time implementation structure.
1. component diagrams
2. deployment diagrams
35. What is component diagram?
Answer:- Component diagrams are used in modeling the physical aspects of object-oriented
systems.
Answer:- Deployment diagrams are used to visualize the topology of the physical components of
a system, where the software components are deployed.
UNIT- 2
1. What is constructor?
Answer:- A constructor is a special type of member function of a class which initializes objects of
a class.
2. What is destructor?
Answer:- A destructor, is used to destroy the objects that have been created by a constructor.
Like a constructor, the destructor is a member function whose name is the same as the class
name but is preceded by a tilde. Eg: ~item() { }
• Default Constructor
• Parameterized Constructor
• Copy Constructor Object
4. What is overloading?
Answer:- It allows multiple definitions of a function with the same name, but different signatures
5. What is default constructor?
Answer:- Default constructor is the constructor which doesn’t take any argument. it has no
parameters.
Answer:- These are the constructors with parameter. Using this Constructor you can provide
different values to data members of different objects, by passing the appropriate values as
argument.
Answer:- These are special type of Constructors which takes an object as argument, and is used
to copy values of data members of one object into other object. It creates a new object, which is
exact copy of the existing copy, hence it is called copy constructor.
8. Features of Polymorphism?
Answer:- Polymorphism means the ability to take more than one form. An operation have
different behaviour in different instances.
Answer:- It means having more constructor with the same name as class name.
Answer:- C++ supports 2 types of polymorphism, 1. Compile time Polymorphism 2. Run time
Polymorphism.
Answer:- The overloaded functions are invoked by matching the type and number of arguments.
This information is available at the compile time and, therefore, compiler selects the appropriate
function at the compile time.
Answer:- Run time polymorphism is achieved when the object's method is invoked at the run
time instead of compile time.
Answer:- Function overloading is a feature of OOPs where two or more functions can have the
same name but different parameters.
• Unary operator loading :- An unary operator means, an operator which works on single
operand.
• Binary operator overloading :- An unary operator means, an operator which works on
two operand.
• Operator Overloading using a friend function
UNIT- 3
1. What is inheritance?
Answer:- The capability of a class to derive properties and characteristics from another class is
called Inheritance.
Answer:-
•Single Inheritance: one derived class inherits from one base class.
•Multiple Inheritance: one derived class inherits from multiple base class(es)
•Multilevel Inheritance: wherein subclass acts as a base class for other classes. i.e a
derived class is created from another derived class.
• Hierarchical Inheritance: wherein multiple subclasses inherited from one base class
• Hybrid (Virtual) Inheritance: Hybrid Inheritance is implemented by combining more
than one type of inheritance. reflects any legal combination of other four types of
inheritance
3. What is base class/ Super class?
Answer:- The class whose properties are inherited by sub class is called Base Class or Super class.
Also known as parent class.
Answer:- The class that inherits properties from another class is called Sub class or Derived Class.
Also know as child class.
5. What are the various mode of inheritance?
1. Public mode
2. Private mode
3. Protected mode
Answer:- Inline function is a function that is expanded in line when it is called. When the inline
function is called whole code of the inline function gets inserted or substituted at the point of
inline function call.
Answer:- A friend function is a function that is declared outside a class, but is capable of
accessing the private and protected members of class.
Answer:- A friend function is a function that is declared outside a class, but is capable of
accessing the private and protected members of class.
Answer:- If derived class defines same function as defined in its base class, it is known as
function overriding in C++.
Answer:- A Virtual function is a member function in the base class whose definition is redefined
in derived classes.
12. Which keyword we use to make function virtual? Answer->> friend keyword.
13. What is Pure Virtual Function?
Answer:- A pure virtual function (or abstract function) in C++ is a virtual function for which we
can have implementation, But we must override that function in the derived class, otherwise the
derived class will also become abstract class.
Answer:- A class containing pure virtual functions cannot be used to declare any objects of its
own. Such classes are called abstract base classes. OR Abstract Class is a class which contains
atleast one pure virtual function in it.
UNIT- 4
1. What is a template?
Answer:- A template is a simple and yet very powerful tool in C++. The simple idea is to pass data
type as a parameter so that we don’t need to write the same code for different data types.
Answer:- Exceptions are run-time anomalies or abnormal conditions that a program encounters
during its execution. Like we need 3 inputs and we get only 2 input, then there will be exception.
Answer:- The try statement allows you to define a block of code to be tested for errors while it is
being executed.
Answer:- The throw keyword throws an exception when a problem is detected, which lets us
create a custom error.
Answer:- The catch statement allows you to define a block of code to be executed, if an error
occurs in the try blocks.
Answer:- If we do not know the throw type used in the try block, you can use the "three dots"
syntax (...) inside the catch block, which will handle any type of exception.
Answer:- Interfaces in C++ are nothing but a way to describe the behavior of a class without any
commitment to any specific implementation of that class.
UNIT- 5
1. What is STL?
Answer:- The Standard Template Library (STL) is a set of C++ template classes to provide
common programming data structures and functions such as lists, stacks, arrays, etc.
3. What is algorithms?
Answer:- Algorithms in the STL are procedures that are applied to containers to process their
data.
5. What is containers?
6. What is iterators?
Answer:- Iterators are a generalization of the concept of pointers, they point to elements in a
container
7. What is functions?
Answer:- The STL includes classes that overload the function call operator. Instances of such
classes are called function objects or functors.
SOME ALGORITHM:-
The find() algorithm looks for an element matching val between start and end
InputIterator find (InputIterator first, InputIterator last, const T& val);
count() returns the number of elements in the given range that are equal to given value.
count(first ,last ,value) :
The search() algorithm used to perform searches for a given sequence in a given range
search(first1 ,last1 ,first2 ,last2)
Sort() algorithm:- This function of the STL, sorts the contents of the given range
sort(start_iterator, end_iterator )
merge() :- Combines the elements in the sorted ranges [first1,last1) and [first2,last2), into a
new range beginning at result with all its elements
OutputIterator merge (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
InputIterator2 last2, OutputIterator result);
The transform() algorithm does something to every item in a container, and places the
resulting values in a different container (or the same one).
OutputIterator transform (InputIterator first1, InputIterator last1, OutputIterator result,
UnaryOperation op);
NOTE:- THERE ARE LOTS AND LOTS OF FUNCTIONS FOR EACH CONTAINER TYPE IN STL(because it’s a
huge topic by itself) . BUT I DON’T THINK THAT THESE FUNCTIONS TYPE OF QUESTION CAN BE ASKED
IN VIVA.