Set - 3

Question 1 :

Differentiate between the message and method.

Answer :

* Objects communicate by sending messages to each other.
* A message is sent to invoke a method.

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

Question 2 :

What is a dangling pointer?

Answer :

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{
		int *ptr;
		Sample(int i){
			ptr = new int(i);
			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;

In the above example when PrintVal() function is called it is called by the pointer that has been freed by the destructor in SomeFunc.

Question 3 :

Differentiate between a template class and class template.

Answer :

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.

Question 4 :

What is a modifier?

Answer :

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;
		x=0; y=0;
	void mod(){


Question 5 :

What do u meant by "SBI" of an object?

Answer :

SBI stands for State, Behavior and Identity. Since every object has the above three.

State: It is just a value to the attribute of an object at a particular time.
Behaviour:It describes the actions and their reactions of that object.Identity:
An object has an identity that characterizes its own existence. The identity makes it possible to distinguish any object in an unambiguous way, and independently from its state.