techpreparation-homepage

Home  Interview Questions  Certifications  Aptitude Questions  Tutorials  Placement Papers  Search  Resume  Soft Skills  Video  Forum  Blog

Android app on Google Play

Technical Interview Questions
Javascript Interview Questions
Oracle Interview Questions
J2EE Interview Questions
C++ Interview Questions
XML Interview Questions
EJB Interview Questions
JSP Interview Questions
                              .........More

Soft Skills
Communication Skills
Leadership Skills
                              .........More

 

 

  

Object Oriented Interview Questions and Answers


Differentiate between the message and method.
Message
* Objects communicate by sending messages to each other.
* A message is sent to invoke a method.

Method
* Provides response to a message.
* It is an implementation of an operation.

What is a dangling pointer?
A dangling pointer arises when you use the address of an object after
its lifetime is over. This may occur in situations like returning
addresses of the automatic variables from a function or using the
address of the memory block after it is freed. The following
code snippet shows this:

class Sample
{
public:
int *ptr;
Sample(int i)
{
ptr = new int(i);
}

~Sample()
{
delete ptr;
}
void PrintVal()
{
cout << "The value is " << *ptr;
}
};

void SomeFunc(Sample x)
{
cout << "Say i am in someFunc " << endl;
}

int main()
{
Sample s1 = 10;
SomeFunc(s1);
s1.PrintVal();
}In the above example when PrintVal() function is
called it is called by the pointer that has been freed by the
destructor in SomeFunc.

Differentiate between a template class and class template.
Template class: A generic definition or a parameterized class not
instantiated until the client provides the needed information. Itís
jargon for plain templates.

Class template: A class template specifies
how individual classes can be constructed much like the way a class
specifies how individual objects can be constructed. Itís jargon for
plain classes.

What is a modifier?
A modifier, also called a modifying function is a member function that changes the value of at least one data member. In other words, an operation that modifies the state of an object. Modifiers are also known as Ďmutatorsí. Example: The function mod is a modifier in the following code snippet:

class test
{
int x,y;
public:
test()
{
x=0; y=0;
}
void mod()
{
x=10;
y=15;
}
};

Page Numbers :  1          2          3         4         5

Have a Question ? post your questions here. It will be answered as soon as possible.

Check Structs Interview Questions for more Structs Interview Questions with answers

Check Job Interview Questions for more Interview Questions with Answers