Set - 3

Question 1 :

Differentiate between the message and method.

Answer :

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.


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{
	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.


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;
	public:
	test(){
		x=0; y=0;
	}
	void mod(){
		x=10;
		y=15;
	}
};

 


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.


Question 6 :

Differentiate the class representation of Booch, Rumbaugh and UML?

Answer :

If you look at the class representation of Rumbaugh and UML, It is some what similar and both are very easy to draw.


Question 7 :

Whether unified method and unified modeling language are same or different?

Answer :

Unified method is convergence of the Rumbaugh and Booch. Unified modeling lang. is the fusion of Rumbaugh, Booch and Jacobson as well as Betrand Meyer (whose contribution is "sequence diagram"). Its' the superset of all the methodologies.


Question 8 :

What is meant by "method-wars"?

Answer :

Before 1994 there were different methodologies like Rumbaugh, Booch, Jacobson, Meyer etc who followed their own notations to model the systems. The developers were in a dilemma to choose the method which best accomplishes their needs. This particular span was called as "method-wars"


Question 9 :

Differentiate Aggregation and containment?

Answer :

Aggregation is the relationship between the whole and a part. We can add/subtract some properties in the part (slave) side. It won't affect the whole part. Best example is Car, which contains the wheels and some extra parts. Even though the parts are not there we can call it as car. But, in the case of containment the whole part is affected when the part within that got affected. The human body is an apt example for this relationship. When the whole body dies the parts (heart etc) are died.


Question 10 :

Why generalization is very strong?

Answer :

Even though Generalization satisfies Structural, Interface, Behaviour properties. It is mathematically very strong, as it is Antisymmetric and Transitive. Antisymmetric: employee is a person, but not all persons are employees. Mathematically all As' are B, but all Bs' not A.