Explain the Concept of Data Abstraction and Data Encapsulation in Object Oriented Programming (OOPS)

October 28, 2007 · Filed Under C++ Questions, Placement Questions

Data encapsulation: the wrapping up of data and functions that act upon that data in a single unit is termed as data encapsulation. It binds together both the data and code and thus keeps both safe from the outside world. The data and the code to manipulate the data are combined in such a way […]

Read the rest of this entry »

What are classes ? How are they defined ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions

A class in an object oriented language is a User defined data type (UDT). A class is made up of member variables (data) and member functions (interface).
A class is created or declared using the class keyword. It defines a new type to represent a real life entity. This type is composed of data that is […]

Read the rest of this entry »

What are objects ? What is common between all objects of a class ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions

Objects are physical or conceptual things that are found in the universe. Objects are thought of having state associated with them. E.g. state of an account would be the account balance; the state of a clock would be the time.
In object oriented terminology a class is just a plain structure and an object is an […]

Read the rest of this entry »

State all the class access modifiers and explain each one of them

October 28, 2007 · Filed Under C++ Questions, Placement Questions

C++ has three access modifiers namely public, private and protected.
Public: a public modifier means that the data or the functions of a class are accessible by any program. There are no restrictions in accessing public members of a class. Ideally all the functions that allow manipulating or accessing the class data are made public.
Private: the […]

Read the rest of this entry »

What are Vectors in C++(Object Oriented Programming) and how are they used ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions

Vector is a part of the sequential container which holds an ordered collection of elements of one type. A vector holds all these elements in a contiguous area of memory. Random access of elements is efficient however insertion of elements at any other position other than the end of the vector is inefficient since each […]

Read the rest of this entry »

What are containers in C++ and in Object Oriented Programming ? Which objects are available as containers ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions

A container is an object that can store other objects as its elements. However all the objects stored in a container should be of the same data type. E.g. array is a container as it allows you to store multiple objects. However there are a few problems with arrays like an array can’t allow you […]

Read the rest of this entry »

What are Iterators in C++ and Object Oriented Programming ? Explain where we use them

October 28, 2007 · Filed Under C++ Questions, Placement Questions

Iterators allow the traversal of a container object. They provide a generic interface to navigate a container without having to know the actual type of its elements. Several member functions of containers like begin () and end () return a pointer to iterators. Begin () returns a pointer to the beginning of a container and […]

Read the rest of this entry »

What are Enumerations in C++ and Object Oriented Programming ? Explain with an example ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions

An enumeration is a type that can hold a set of constant values that are defined by the user. Once you define an enumeration you can use it like integer types.
E.g. enum {OFF, ON};
The enum defines two integer constants called enumerators and these constants are assigned values by default. The value assigned to OFF = […]

Read the rest of this entry »

What do you mean by “Pointers to Function”? What are Function Pointers ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions

We can use a function in two ways: one is to invoke a function and the second is to obtain the address of a function. This address that is obtained is called as pointer to the function and is used to invoke the function.
E.g. we have a function named display and we will invoke this […]

Read the rest of this entry »

What is the Exception Handling mechanism in C++ ? What is Try and Catch in C++ ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions

The ability to gracefully handle an error or an exception is known as exception handling. C++ has built exception handling techniques which allows the program to handle and exceptions and deal with them.
- try block: the code that is likely to throw an exception should be enclosed […]

Read the rest of this entry »