What is the difference between Mutex and
semaphore is used to synchronize processes. where as mutex is used to
provide synchronization between threads running in the same process.
In C++, what is the difference between method overloading and method
Overloading a method (or function) in C++ is the ability for functions
of the same name to be defined as long as these methods have different
signatures (different set of parameters). Method overriding is the
ability of the inherited class rewriting the virtual method of the base
What methods can be overridden in Java?
In C++ terminology, all public methods in Java are virtual. Therefore,
all Java methods can be overwritten in subclasses except those that are
declared final, static, and private.
What are the defining traits of an object-oriented language?
The defining traits of an object-oriented langauge are:
Write a program that ask for user input from 5 to 9 then calculate
int total =0;
cout<<"Please enter your input from 5 to 9";
cout<<"please re type your input";
total = total + numb;
average= total /MAX;
cout<<"The average number is"<<average<<endl;
Assignment Operator - What is the diffrence between a "assignment
operator" and a "copy constructor"?
In assignment operator, you are assigning a value to an existing object.
But in copy constructor, you are creating a new object and then
assigning a value to that object. For example:
c1=c2; //this is assignment
complex c3=c2; //copy constructor
A copy constructor is used to initialize a newly declared variable from
an existing variable. This makes a deep copy like assignment, but it is
There is no need to test to see if it is being initialized from itself.
There is no need to clean up (eg, delete) an existing value (there is
A reference to itself is not returned.
RTTI - What is RTTI?
RTTI stands for "Run Time Type Identification". In an inheritance
hierarchy, we can find out the exact type of the objet of which it is
member. It can be done by using:
1) dynamic id operator
2) typecast operator
RTTI is defined as follows: Run Time Type Information, a facility that
allows an object to be queried at runtime to determine its type. One of
the fundamental principles of object technology is polymorphism, which
is the ability of an object to dynamically change at runtime.
STL Containers - What are the types of STL containers?
There are 3 types of STL containers:
1. Adaptive containers like queue, stack
2. Associative containers like set, map
3. Sequence containers like vector, deque
What is the need for a Virtual Destructor ?
Destructors are declared as virtual because if do not declare it as
virtual the base class destructor will be called before the derived
class destructor and that will lead to memory leak because derived
class’s objects will not get freed.Destructors are declared virtual so
as to bind objects to the methods at runtime so that appropriate
destructor is called.