ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories >> Software >> Programming-Languages >> C++
 
  STL (45)  OOPS (186)  C++-General (222)
 


 

Back to Questions Page
 
Question
In which cases you use override and new base?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
Use the new modifier to explicitly hide a member inherited 
from a base class. To hide an inherited member, declare it 
in the derived class using the same name, and modify it 
with the new modifier.
 
0
Swetcha
 
 
Question
Can we call a base class method without creating instance?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
With :: operator
 
0
Rajesh
 
 
Answer
U've to derieve the class first and then when u instanciate 
the derieved class. Then :-

U can call it using derieved class object or in a derieved 
class member function depending upon base class fun's acess 
specifer and inheritence specifier.
 
0
Amit Sharma
 
 
 
Answer
e.g. class X
{
       int x;
       X()
       {
           cout << "X";
       }
       public :
       static void fun()
       {
            cout << "fun";
       }
};

you may called like
X::fun();
 
0
Sanjay Makwana, Puna
 
 
Answer
Onlu static methods can be called without creating any 
instance of the class.
 
0
Nk
 
 
Question
What is Method overloading?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
Method overloading occurs when a class contains two methods 
with the same name, but different signatures
 
0
Swetcha
 
 
Answer
when a class has two same method names with different
parameters then it is called method overloading
 
0
Anandan
 
 
Answer
a class can have more than one method with same function 
name but different in parameter passing is said to be 
method overloading
 
0
Saranya
 
 
Answer
A class having more then two method with the same name but 
different signature.
 
0
Abhishek Kumar
 
 
Question
What is Inheritance, Multiple Inheritance, Shared and
Repeatable Inheritance?
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   Accenture
I also faced this Question!!   © ALL Interview .com
Answer
The mechanism of deriving a new class from an old one is 
called inheritance.the old ones is called the base class 
and the new one is called the derived or sub class.
MULTIPLE INHERIENCE:one depived class from many base class 
is reffered to MI.
 
0
Mahesh Kumar
 
 
Answer
Inheritence is the mechanisum by which one obj aquiers the
properties of another object .By which we can achhive the
hirearchial classiffication.
 
1
Srinivas
 
 
Answer
Inheritence is defined as the mechanism of deriving a new 
class from an already existing class.The class from which 
new class derived is called parent or bae class and the 
derived one is called derived class.The new derived class 
will have the characteristics of its own and the base class.
The main purpose of using inhertence concept is that 
nothing but the reusability of code.Muliple inheritence 
means deriving a new class from one or more base class.
 
0
Vidhya Alphonse
 
 
Question
What is Object and Class? What are the differences between
them?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
simple analogy for this quest is u declare int x;
and u ask diff between int and x;


Object is an instance of a class.......
   --when an object of a class is created the memory for 
that class is created...
   --U can access the class members using the . operator in 
your program....but u r not allowed to access the private 
and protected members, which can be accessed by the member 
functions only........

Class is the user defined datatype...which contains data 
members and member functions.....
 
0
Jack
 
 
Answer
object-run time entity
class- bind of function & data
 
0
Kalaivani
 
 
Answer
Class is template for creating similar type of entities. 
Class doesn't take memory space untill it contains static 
members.
In a specific Class, you declare the attributes(field 
variables) and its behaviour(functions).
But Class doesn't have any state and identity.

Objects are the real time entity which are created through 
their template, thier class.
By real time entity, I mean they would occupy a memory 
space in which they will save the values of its atrributes. 
These values create a state of an object.
Since Object occupy a space in memory so they have unique 
address in memory. This become the identity of an object.

For example : Pen is a class, which has weight and color as 
its attribute. They may have behaviour like write().

Still they don't occupy a space in memory.

When I say My pen ,It will be an object of class Pen since 
it will have some values for weight like 10 gm and color 
like blue. This will occupy some memory to save these 
values.
 
0
Pankaj Vashishta
 
 
Question
What are the OOPS concepts?
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   Wipro , Eds, MNC
I also faced this Question!!   © ALL Interview .com
Answer
1) Encapsulation: It is the mechanism that binds together 
code and data in manipulates, and keeps both safe from 
outside interference and misuse. In short it isolates a 
particular code and data from all other codes and data. A 
well-defined interface controls the access to that 
particular code and data.
2) Inheritance: It is the process by which one object 
acquires the properties of another object. This supports 
the hierarchical classification. Without the use of 
hierarchies, each object would need to define all its 
characteristics explicitly. However, by use of inheritance, 
an object need only define those qualities that make it 
unique within its class. It can inherit its general 
attributes from its parent. A new sub-class inherits all of 
the attributes of all of its ancestors.
3) Polymorphism: It is a feature that allows one interface 
to be used for general class of actions. The specific 
action is determined by the exact nature of the situation. 
In general polymorphism means "one interface, multiple 
methods", This means that it is possible to design a 
generic interface to a group of related activities. This 
helps reduce complexity by allowing the same interface to 
be used to specify a general class of action. It is the 
compiler's job to select the specific action (that is, 
method) as it applies to each situation
 
2
Swetcha
 
 
Answer
Object oriented programming organizes a program around it's 
data i.e objects and a set of well defined interface to 
that data. An Object-oriented program can be characterized 
as data controlling access to code.
 
0
Janet
 
 
Answer
The concepts of OOPs are


Objects
Data abstraction 
Data Encapsulation
Inheritance
Overloading 
Polymorphism

And easy to use
 
0
Srividhya
 
 
Answer
message passing
 
0
Hi
 
 
Answer
objects
interface
polymorphism
inheritence
constructors
encapsulation
 
0
Satya
 
 
Answer
Object-oriented programming (OOP) is a computer science 
term used to characterize a programming language that began 
development in the 1960’s. The term ‘object-oriented 
programming’ was originally coined by Xerox PARC to 
designate a computer application that describes the 
methodology of using objects as the foundation for 
computation. By the 1980’s, OOP rose to prominence as the 
programming language of choice, exemplified by the success 
of C++. Currently, OOPs such as Java, J2EE, C++, C#, Visual 
Basic.NET, Python and JavaScript are popular OOP 
programming languages that any career-oriented Software 
Engineer or developer should be familiar with.
 
2
Siva
 
 
Answer
OOPs concepts are
1)object
2)class
3)encapsulation
4)abstraction
5)polymorphism
6)inheritance
7)message passing
8)dynamic binding
    These all are partially supported by c++,java supports
all the above features
 
0
Suresh Ragala
 
 
Answer
There are only five concepts in the oops others may be
derived from those:
1. Encapsulation and Data Abstraction
2. Polymorphism
3. Dynamic Binding
4. Message Passing
5. Inheritance
 
0
Mayank Gupta
 
 
Answer
OOPs concepts are
1)object
2)class
3)encapsulation
4)abstraction
5)polymorphism
6)inheritance
7)message passing
8)dynamic binding
    These all are partially supported by c++,java supports
all the above features
 
0
Ramesh
 
 
Answer
OOPs define software as a collection of discrete oblects 
that specify both data structure and behavior. OOPs 
Identify following aspects:
Data abstraction, Inheritence, Polymorphism, Encapsulation
(information hiding)etc.
 
0
Ajay Kumar(me-se-tu)
 
 
Answer
The following are the basic concepts of OOPS.
1)Objects
2)Classes
3)Data Abstraction
4)Data Encapsulation
5)Inheritance
6)Polymorphism
7)Message Passing
8)Reusability
9)Dynamic Binding
10)Methods
 
0
Rithi
 
 
Answer
1)Object-Instance of the class
2)Classes-Combination of Data members and member functions
3)Data Abstraction-Abstracting the data and functions from
unwanted users.
4)Data Encapsulation-Wrapping up of Data members and member
functions.
5)Inheritance-Passing the values from one object to anther
object.
6)Message Passing-Messages can possible from one object to
anther object
7)Polymorphism-its like function over loading. 
Poly-Many, morphism-Forms
8)Robust and Securisam-its for security purpose
 
0
Sivabalaselvamani
 
 
Answer
The concepts of OOPs are Objects Data abstraction Data 
Encapsulation Inheritance Overloading .
 
0
V.rajaram
 
 
Answer
class
objects
inheritance and its types
data abstraction
data encapsulation
polymorphism
overriding and overloading
dynamic binding
 
0
Shajahan
 
 
Answer
oops concepts means to provide security of our data.
oops concepts are following ways:
Encapsulation: wrapping up of data and member function 
together into a single unit class.
Abstraction: Showing essential feature without background 
detail.
Inheritance: The property of one class inherited property 
of other class.
Polymorphism: it means many form .They are two forms as:
Operator overloading and Function overloading.
 
0
Irfan Jafree
 
 
Answer
BASIC CONCEPT OF OOPS:
1.OBJECTS:
An object is an abstraction of a real world entity. It may 
represent a person,a placea number and icons or something 
else that can be modelled.Any data in an object occupy some 
space in memory and can communicate with eachother . 
2.CLASSES:
A class is a collection of objects having common 
features .It is a user defined datatypes which has data 
members as well functions that manupulate these datas.
3.ABSTRACTION:
It can be definr\ed as the seperation of unnecessary 
details or explation from system requirments so as to 
reduce the complaxities of understanding requirments.
4.ENCAPTULATION:
It is a mechanism that puts the data and function together. 
It is bthe result of hiding implimintation details of an 
object from its user .The object hides its data to de 
accessed  by only those functions which are packed in the 
class of that object.
5.INHERITANCE:
It is the relationship between two classes of object such 
that one of the classes ,the child takes all the relevent 
features of other class -the parent.
Inheritance bring about  reusablity.
6.POLYMORPHISM:
polymorphism means having many forms that in a single 
entity can takes more than one form.Polymorphism is 
implemented through operator overloading and function 
overloading.
7.DYNAMIC BINDING:
Dynamic binding is the proces of resolving the function to 
be associated with yhe respective functions calls during 
their runtime rather than compile time.
8.MESSAGE PASSING:
Every data in an objest in oops that is capable of 
processing request known as message .All object can 
communicate with each other by sending message to each other
 
0
Manila
 
 
Answer
How can a class become collection of objects???
 
0
Geek
 
 
Answer
OOPs concepts are
1)object
2)class
3)encapsulation
4)abstraction
5)polymorphism
6)inheritance
7)message passing
8)dynamic binding
BASIC CONCEPT OF OOPS:
1.OBJECTS:
An object is an abstraction of a real world entity. It may 
represent a person,a placea number and icons or something 
else that can be modelled.Any data in an object occupy some 
space in memory and can communicate with eachother . 
2.CLASSES:
A class is a collection of objects having common 
features .It is a user defined datatypes which has data 
members as well functions that manupulate these datas.
3.ABSTRACTION:
It can be definr\ed as the seperation of unnecessary 
details or explation from system requirments so as to 
reduce the complaxities of understanding requirments.
4.ENCAPTULATION:
It is a mechanism that puts the data and function together. 
It is bthe result of hiding implimintation details of an 
object from its user .The object hides its data to de 
accessed  by only those functions which are packed in the 
class of that object.
5.INHERITANCE:
It is the relationship between two classes of object such 
that one of the classes ,the child takes all the relevent 
features of other class -the parent.
Inheritance bring about  reusablity.
6.POLYMORPHISM:
polymorphism means having many forms that in a single 
entity can takes more than one form.Polymorphism is 
implemented through operator overloading and function 
overloading.
7.DYNAMIC BINDING:
Dynamic binding is the proces of resolving the function to 
be associated with yhe respective functions calls during 
their runtime rather than compile time.
8.MESSAGE PASSING:
Every data in an objest in oops that is capable of 
processing request known as message .All object can 
communicate with each other by sending message to each other
 
0
Ponnurajesh
 
 
Answer
These Are Four Main OOPS Concepts::-->>

1.Polymorphism
2.Inheritence
3.Abstract
4.Encapsulation
 
0
Anurudh Singh
 
 
Question
Explain the ISA and HASA class relationships. How would you 
implement each in a class design?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
A specialized class "is" a specialization of another class 
and, therefore, has the ISA relationship with the other 
class. 
This relationship is best implemented by embedding an 
object of the Salary class in the Employee class.
 
0
Guest
 
 
Answer
"ISA" a relationship is aka Inheritance and used to extent
the  capability of Base, whereas "HASA" relationship is aka
Containment use to take the all properties of BASE.
 
0
Nishikant Sahu
 
 
Question
Can you explain the term "resource acquisition is 
initialization?"
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
RAAI is the concept of releasing the aquired
memory/resources when the object goes out of scope.
E.g. std::auto_ptr
 
1
Melos
 
 
Question
Why do C++ compilers need name mangling?
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   Lucent
I also faced this Question!!   © ALL Interview .com
Answer
Name mangling is the rule according to which C++ changes 
function's name into function signature before passing that 
function to a linker. This is how the linker differentiates 
between different functions with the same name.
 
0
Guest
 
 
Question
How do you know that your class needs a virtual destructor?
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   Lucent
I also faced this Question!!   © ALL Interview .com
Answer
If your class has at least one virtual function, you should 
make a destructor for this class virtual. This will allow 
you to delete a dynamic object through a baller to a base 
class object. If the destructor is non-virtual, then wrong 
destructor will be invoked during deletion of the dynamic 
object.
 
0
Guest
 
 
Answer
If programmer intended to act the class as a BASE class
somewhere then it is rule of thumb or good programming that
you have to have declare your constructor virtual.
 
0
Nishikant Sahu
 
 
Answer
If the class will be derived from and it will need a virtual
destructor so that the destructor of the derived class will
be invoked if it referenced using the pointer to the base class.
 
0
Melos
 
 
Question
What is Pure Virtual Function? Why and when it is used ?
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   Lucent
I also faced this Question!!   © ALL Interview .com
Answer
The abstract class whose pure virtual method has to be 
implemented by all the classes which derive on these. 
Otherwise it would result in a compilation error.
This construct should be used when one wants to ensure that 
all the derived classes implement the method defined as 
pure virtual in base class. 
 
0
Guest
 
 
Answer
in inheritance if the base class contains a virtual 
function equating to zero, it is known also as do-nothing  
function & that base class is called as abstract base class 
as there are no instances or objects can be created by this 
base class. And this pure virtual can be filled with the 
codes in successiv derived classes accordin to the user 
requirements.
          The syntax of the pure virtual function is....
          
      class class_name
      {
         visibility mode:\\should be protected:
         virtual return_type function_name()=0;
       }
      new class_name : inheritance_type old class_name
       {
         ........  //class body
         ........
        }
 
4
Ognas(shradha-asutosh)
 
 
Answer
Virtual function vs pure virtual function :

Virtual function :-

1. Virtual function have a function body.
2. Overloaded can be done by the virtual funciton. 
(Optional)
3. It is define as : virtual int myfunction();


Pure virtual function :-

1. Pure virtual function have no function body.
2. Overloading is must in pure virtual funciton. (Must)
3. It is define as : virtual int myfunction() = 0;
4. A class is "abstract class" when it has at least one 
pure virtual function.
5. You cann't create instance of "abstract class", rather 
you have to inherit the "abstract class" and overload all 
pure virtual function.

Like :- CControlBar class is an "abstract class".
 
0
Mahfuzur Rahman
 
 
Answer
A virtual function that is initialized to zero (0) is 
referred to as pure virtual function.It has no body and 
hence also known as do-nothing or the dummy function.
Example: virtual void show()=0;

A class containing one or more pure virtual functions is 
called an Abstract class, which means an instance of such 
class can't be created (but pointer to that class can be 
created).We should use pure virtual function if we do not 
want to instantiate a class but make it act as a base class 
for all the classes that derive from it.An important thing 
to note about pure virtual functions is that these 
functions must be overridden in all the derived classes 
otherwise the compile would flag out an error.

Sample program:

class alpha
{
public:virtual void show()=0; //pure virtual function
};
class beta:public alpha
{
public:void show()   //overriding
       {
       cout<<"OOP in C++";
       }
};
void main()
{
alpha *p;
beta b;
p=&b;
p->show();
}

Output: OOP in C++
 
0
Apple Dugar
 
 
Question
Why is it difficult to store linked list in an array?
Rank Answer Posted By  
 Question Submitted By :: Tina Saha
This Interview Question Asked @   Lucent
I also faced this Question!!   © ALL Interview .com
Answer
Because array can not grow dynamically
 
0
Murali
 
 
Answer
array can grow dynamically...........

but it is a waste of memory to set them to grow dynamically
 
0

 
 
Question
How can you find the nodes with repetetive data in a linked 
list?
Rank Answer Posted By  
 Question Submitted By :: Tina Saha
This Interview Question Asked @   Lucent
I also faced this Question!!   © ALL Interview .com
Answer
By parsing/processing the nodes 
we attain O(n) to O(log(n)) depending on the type of data-
structure
 
0
Murali
 
 
Question
How can you quickly find the number of elements stored in a 
a) static array b) dynamic array ?
Rank Answer Posted By  
 Question Submitted By :: Tina Saha
This Interview Question Asked @   Lucent
I also faced this Question!!   © ALL Interview .com
Answer
static array
 
0
Guest
 
 
Answer
for static array start from highest index to lowest ( 
normal conditions apply*)
if dynamic array is a Container type, size() / length() 
will do. if not process the nodes.
 
0
Murali
 
 
Answer
a) sizeof(array)/sizeof(element)
b) you cant (well, you can, eg. by using realloc, counting
from 0 up, and checking the result etc. but this is absurd),
its best to keep track somehow how many elements are there
in the array, but the BEST solution is...do NOT use dynamic
arrays at all, use std containers instead like vector.
 
0
Jaroosh
 
 
 
Back to Questions Page
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com