Assignment 1 Object Oriented Programming
Assignment 1 Object Oriented Programming
Explain all the features of object oriented programming which you will be using in C++.
2. Differentiate call by value, call by address, and call by reference with example.
4. Can we use the same function name for a member function of a class and an outsidefunction in
the same program file? If yes, how are they distinguished? If no, give reasons.
5. What is inline function? Discuss the pros and cons of using inline function with example.
6. Discuss the advantages of using function with default arguments as compared to function
overloading with example. Also discuss the possible conflict which may arise when both the features
are combined.
9. Discuss the various access methods used in c++ with respect to their scope and life time.
10. Explain the need of static data members in a class through an example. Why this pointer can not
be used with the static members of the class?
11. What does this pointer point to? Mention the applications of this pointer through examples?
12. What is a constructor? Discuss the different types of constructors and mention when it is
mandatory to define a constructor of a class.
13. Can we have a constructor with default arguments? Justify your answer.
14. Mention all the scenarios when the copy constructor is going to be invoked and replicate those
scenarios through examples. Why does copy constructor accept the objects by reference and not by
value.
15. Can we have more than one constructors in a class? If yes, explain the need for such a situation.
16. Describe the need of defining a explicit copy constructor in a program through examples.
17. Differentiate between shallow copy and deep copy while copying an existing object to a new
object.
19. Why call by address and call by reference is preferred over call by value while passing an object
as an argument to a function.
20. Is there any way to access class private members without its object? Justify your answer.
22. In what order are the class constructors called when a derived class object is created?
23. Differentiate between compile and run-time polymorphism. Explain how run-time polymorphism
is achieved in c++ using an example.
26. Write a c++ program using class to represent a bank account. Include the following members:
Data members:
2. Account number.
3. Type of account.
Member functions:
2. To deposit an amount.
27. Write a c++ program using class to take the input of a fraction in terms of numerator and
denominator, then simplify and display the same.
28. Write a c++ program using class to add two numbers using this pointer.
29. Write a c++ program using class to display the name of the topper in the class.
30. Write a c++ program using class that has array of integers as data members and input(),display(),
find_largest(), find_smallest(), and sum() as its member function to carry out the desired task.
31. Write a c++ program using class to exchange two inter members of a class. Use friend function,
pointer to data member, and pointer to member function.
32. Write a c++ program using class to dynamically allocate two integer arrays and add them in a
third array.
33. Write a c++ program using class that concatenate two strings defined as private members in a
class using friend function. The strings to be concatenated must belong to object S1 and S2 of class
string.
34. Write a c++ program using class that uses dynamic constructor to allocate memory to an array.
Count the number of even and odd elements. Finally free the dynamically allocated memory.
Write a c++ program using class to dynamically allocate memory to string objects. Use copy
constructor to copy one string to another.
useful in OOP?
-oriented program.
-oriented programming? How it is different from the procedure-oriented
programming?
concept of OOP.