Beruflich Dokumente
Kultur Dokumente
1. What is a class?
Class is concrete representation of an entity. It represents a group of objects, which hold similar attributes and
behavior. It provides Abstraction and Encapsulations. Classes are generally declared using the keyword class.
Object represents/resembles a Physical/real entity. An object is simply something you can give a name.
objects and enables code-reuse. Object is a software bundle of variables and related methods.
Objects have state and behavior. object is a real life entity which contains data and functions
to operate on that data.
3. What is Encapsulation?
Encapsulation is binding of attributes and behaviors. Hiding the actual implementation and exposing the
functionality of any object. Encapsulation is the first step towards OOPS, is the procedure of covering up
of data and functions into a single unit (called class). Its main aim is to protect the data from out side
world
4. What is Abstraction?
Hiding the complexity. It is a process of defining communication interface for the functionality and
5. What is Overloading?
Adding a new method with the same name in same/derived class but with different number/types of
6. What is Inheritance?
It is a process in which properties of object of one class acquire the properties of object of another
class.
An abstract class is a special kind of class that cannot be instantiated. It normally contains one or more
Poly" means "many" and "morph" means "form". Polymorphism is the ability of an object (or
reference) to assume (be replaced by) or become many different forms of object.
Example: function overloading, function overriding, virtual functions. Another example can
be a plus? +? sign, used for adding two integers or for using it to concatenate two strings
There are two types of polymorphism-
1)Run time polymorphism –Address of the function determine at the runtime is
known as runtime polymorphism
2) Compile time polymorphism- Address of the function determine at the compile
time is known as runtime polymorphism
9. What do you mean by iostream.h?
1. Public: The data members and methods having public as access outside the class.
2. Protected: The data members and methods declared as protected will be accessible to the class methods
and the derived class methods only.
3. Private: These data members and methods will be accessible not from objects created outside the class.
Ex - int a=5
Tell the
compiler
about the
variable: its
type and
name, as
well as
allocated a
memory
cell for
the variable
Declaration
Ex- int a
Describe
information
``about'' the
variable,
variable,
doesn’t
allocate
memory
cell for the
variable
A void return type indicates that a method does not return a value.
A nested class is a class enclosed within the scope of another class. For example: // Example
1: Nested class // class Outer Class {class Nested Class {// …}; //...
Tokens - The smallest individual units in a program are known as tokens, c++ has the following tokens:
Example of tokens: - }, {, “ “, int
Keywords
Identifiers
Constants
Identifier:
In our everyday, we give names to different things so they can be
Referred easily. Similarly, in C+, we use identifiers to name user created entities
Which may be?
• Variable
• Function
Constructor with no arguments or all the arguments has default values. In Above Question Test() is a
default constructor
As the name suggests, the function acts as a friend to a class. As a friend of a class, it can access its
private and protected members. A friend function is not a member of the class. But it must be listed in
A scope resolution operator (::), can be used to define the member functions of a class outside the
class.
A pure virtual member function is a member function that the base class forces derived classes to
provide. Normally these member functions have no implementation. Pure virtual functions are equated
};
It permits code reusability. Reusability saves time in program development. It encourages the reuse of
proven and debugged high-quality software, thus reducing problem after a system becomes functional
26 What are virtual functions? Describe a circumstance in which virtual functions would be appropriate
Virtual functions are functions with the same function prototype that are defined throughout a class
hierarchy. At least the base class occurrence of the function is preceded by the keyword virtual. Virtual
functions are used to enable generic processing of an entire class hierarchy of objects through a base
class pointer. For example, in a shape hierarchy, all shapes can be drawn. If all shapes are derived from
a base class Shape which contains a virtual draw function, then generic processing of the hierarchy can
be performed by calling every shape’s draw generically through a base class Shape pointer.
27 Distinguish between virtual functions and pure virtual functions
A virtual function must have a definition in the class in which it is declared. A pure virtual function does
not provide a definition. Classes derived directly from the abstract class must provide definitions for the
inherited pure virtual functions in order to avoid becoming an abstract base class
Parameter –While defining method, variable passed in the method are called parameters.
Arguments-While using those methods value passed to those variables are called arguments.
Keywords are predefined reserved identifiers that have special meanings. They cannot be used as
identifiers in your program. Keyword is a word that the compiler already knows, i.e. when the compiler
sees a keyword somewhere in the program it knows what to do automatically.
For example, when the compiler encounters the keyword ‘int’, it knows that ‘int’ stands for an
integer. Or if the compiler reads a ‘break’, then it knows that it should break out of the current
loop.