Sardar Patel University 2006 B.E Computer Science CP312 – Object-Oriented Programming(Internal ) - Question Paper
Tuesday, 29 January 2013 10:45Web
Page 1 of 2
GCET
CP312 – Object-Oriented Programming
AY: 2006-07, SEM – I
Solution of first Internal Test paper
Q-1
[a]
1. Purpose of scope resolution operator:
? It allows a program to reference an identifier in the global scope that has been hidden by a different identifier with the identical name in the local scope.
? E.g.
int n=10;
main()
{
int n=20;
cout<
}
Marks Distribution: 0.5 mark for mentioning the purpose and 0.5 mark for giving the example.
2. Data Abstraction:
? The technique of creating new data kinds that are well suited to an application to be programmed is known as data abstraction
? It provides the ability to create the user-defined data types, for modeling a real world object, having the properties of built-in data kinds and a set of permitted operators.
info Hiding:
? It is a mechanism that associate the code and the data it manipulates into a single unit and keep them safe from external interference and misuse
Marks Distribution: 0.5 mark for every definition.
3. We cannot overload “=” operator by using the friend function
because friend functions donot support this pointer.
Marks Distribution: one mark for accurate ans.
4. “This” pointer:
? “This” is a pointer that is automatically passed to any member function when it is called.
? It points to the object that generates the call to the function.
? Only the member functions are passed a “this’ pointer.
? A Friend function does not have “this” pointer.
? E.g. obj.func();
func() function is automatically passed a pointer to object obj(which is the object invokes the call). This pointer is referred to as “this”.
Marks Distribution: one mark for defining and explaining correctly as mentioned above
5. Automatic inline function:
? When a function is inline then the function is not called but it is expanded in line of the function call.
? When a function is described in the class then it automatically becomes an inline function.
? Inline is not a command it is a request.
? Then there is no longer need to mention inline keyword.
? E.g.
class myclass
{
int i,j;
public:
myclass(int n,int m);
int mul()
{
return i*j;
}
};
myclass::myclass(int n,int m)
{
i=n;j=m;
}
void main()
{
myclass ob(10,20);
cout<
? Here mul() function is described in the class so it automatically becomes inline function.
Marks Distribution: 0.5 mark for defining and 0.5 mark for giving the accurate example.
6. Need of friend function:
? Friend function is needed when we want to access the private member of 2 or more various classes.
Earning: Approval pending. |