1. Q1:Define Inheritance? Name various types of
Inheritance?
Inheritance is a feature or a process in which, new
classes are created from the existing classes. The
new class created is called “derived class” or “child
class” and the existing class is known as the “base
class” or “parent class”. The derived class now is
said to be inherited from the base class.
2.
3. Q:-What pure virtual function?
Pure virtual functions in C++ are virtual
functions with no definition. We use the
keyword “virtual” in C++ to declare a
virtual function. They are assigned a value
of zero when they are declared.
Syntax:- virtual void f()=0;
4. Q:-What is data hiding?How it is
achieved in C++?
Data hiding is a technique of hiding
internal object details, i.e., data
members. It is an object-oriented
programming technique. Data
hiding ensures, or we can say
guarantees to restrict the data
access to class members. It
maintains data integrity.
5. Example: We can understand data hiding
with an example. Suppose we declared an
Account class with a data member balance
inside it. Here, the account balance is
sensitive information. We may allow
someone to check the account balance but
won’t allow altering the balance attribute.
So, by declaring the balance attribute
private, we can restrict the access to
balance from an outside application.
6. It can be achieved by using private
and protected specificer
7. Q:-What is array of an object? Explain
an example?
In the array of object in C++, each element
of an array becomes an object (same
class’s), which means the array of object in
C++ is a collection of objects of the same
class. Just as an object is a collection of
data-members and function-members. so
each element of an array is a collection of
data-member and function-member.
8. Q:-What is function overoading? Give
example?
Function overloading is a feature of object-
oriented programming where two or more
functions can have the same name but
different parameters. When a function name
is overloaded with different jobs it is called
Function Overloading. In Function
Overloading “Function” name should be the
same and the arguments should be
different.
9. Q:- What are the various data types
supported by C++?
C++ supports a wide variety of data
types and the programmer can select
the data type appropriate to the needs
of the application. Data types specify
the size and types of value to be
stored.
10. Data types in C++ are mainly divided into
three types:
1. Primitive Data Types: These data types are
built-in or predefined data types and can be
used directly by the user to declare variables.
Primitive data types available in C++ are:
int
float
char
double
11. 2.Derived Data Types: The data types that are
derived from the primitive or built-in datatypes
are referred to as Derived Data Types. These
can be of four types namely:
Function
Array
Pointer
Reference
12. 3.Abstract or User-Defined Data Types:
These data types are defined by the user
itself. Like, as defining a class in C++ or a
structure. C++ provides the following user-
defined datatypes:
Class
Structure
Union
Enumeration
Typedef
13. Q1:-Compare public,private, protected
visibility modes ?
Public Access Modifier in C++All the
variables and functions declared under
the public access modifier will be
available for everyone. They can be
accessed both inside and outside the
class. Dot (.) operator is used in the
program to access public data members
directly.
14. Private access modifier
All the variables and functions declared
under a private access modifier can only
be used inside the class. They are not
permissible to be used by any object or
function outside the class.
15. Protected Access Modifiers
C++Protected access modifiers are
similar to the private access modifiers
but protected access modifiers can be
accessed in the derived class whereas
private access modifiers cannot be
accessed in the derived class.
16. Multiple Inheritance: Multiple
Inheritance is a feature of C++
where a class can inherit from more
than one class. i.e one subclass is
inherited from more than one base
class.
17. Q:-Discuss various stream classes in C++?
In C++ there are number of stream
classes for defining various streams
related with files and for doing input-
output operations. All these classes
are defined in the file iostream.h.
Figure given below shows the
hierarchy of these classes.
18. Ios class is topmost class in the stream
classes hierarchy. It is the base class
for istream, ostream, and streambuf
class.
Istream and ostream serves the base
classes for iostream class. The class
istream is used for input and ostream
for the output.