Saturday, October 18, 2014

OOPS AND OOAD important questions for UGC NET computer science  C++


1. What is the difference between a pointer and reference?

Ans.: A pointer can both be initialized and assigned whereas
A reference can only be initialized.

Explanation:

int w, *x, &y;
x=&w;

2. When does memory leak occur?

Ans.: Memory leak occurs when the program loses the ability to free a block of dynamically allocated memory.

3. Operators that cannot be overloaded?
Ans.: sizeof  .   .*  .->   ::   ?:


 4. Functions that cannot be inherited in C++
Ans.: Constructors
Destructors
User defined new operators
User defined assignment operators
Friend relationships

5. Check the validity of the statement

Statement: Can an assignment operator be declared as friend.
Ans.: False
Reason: An assignment operator can only be declared as a member function and never as a friend.

6. When does a bad_alloc exception occur?

Ans.: It occurs when 'new' operator fails to find the space needed to allocate memory for the object.

7. What is one definition rule (ODR)?

Ans.: It is a requirement that global objects  and functions have a single definition or same definition many times in a program.

8. Who invented C++ and who coined the term '++'?

Ans.: Bjarne Stroustrup, Rick Mascitti

9. Check the validity of the statement

Statement: Arrays can store Non-homogenous data.
Ans.: False
Reason: Arrays can  store only homogenous(similar) data of the same data type that are referenced
by a common name.

10. What information hiding?

Ans.: Separating the implementation of the class from its user.

11. Expand SBI.
Ans.: S-State
B-Behaviour
I-Identity

12. What are the similarities of constructors and destructors.
Ans.: Both do not have return value declaration.
They cannot be inherited
Their addresses cannot be extracted.(& -reference not possible).


13.. What is a class invariant?
Ans.: It is a condition that defines all valid states for an object.
It is a logical condition to ensure the correct working of a class.

14. What are proxy objects?
Ans.: They are objects that points to other objects.
They are also called as surrogates and provide the same interface as its server object and have no special functionality.

15. What is cloning?
Ans.: It is a technique that returns a copy of itself.

16. Difference between static model and dynamic model?
Ans.: Static model is used to specify structure of the objects present in the problem domain.
Dynamic model means representing the object interactions during run time.

17. Themes of object oriented programming
Ans.: Objects,messages,class,inheritance,polymorphism.

18. Example of active and passive object
Ans.: Active object- Client
Passive object- Server

19. What is generalization and types of generalization?
Ans.: It is used to represent a class,which captures the common states of object of different classess.

G.Booch model
Rumbaugh's model
Jacobson's model

20. what is null object?
Ans.: It is an object of some class that is used to indicate that a real object of that class does not exist.

21. What an accessor?
Ans.: It is a class operation that does not modify the state of an object.

22. What is an adaptor class?
Ans.: It is a class that has no functionality of its own.
It is also called as wrapper class.

Gear up your Preparation!!!

No comments:

Post a Comment