Practice Questions OOP
Practice Questions OOP
Questions:
1. List different access specifiers used in Inheritance and Describe use of private access
specifier used in the class.
2. List different access specifiers used in Inheritance and Describe use of protected access
specifier used in the class.
3. List different access specifiers used in Inheritance and Describe use of public access
specifier used in the class.
4. Define multilevel inheritance. Draw the diagram to show multilevel inheritance. using classes
with data member and member function.
5. Define multiple inheritance. Draw the diagram to show multiple inheritance. using classes with
data member and member function.
12. Give syntax to define derived class constructor and describe the order of execution of
constructor for following Figure.
13. Describe the use of Virtual Function.
14. Describe the use of pure Virtual Function.
15. Describe the use of abstract base class.
16. Give meaning of following statements:
int a[5]={1,2,3,4,5};
int * ptr;
ptr = & a ;
cout << * ptr<<”\n” ;
cout << ptr++;
cout << * ptr<<”\n” ;
19. Write a C++ program to implement following in heritance. Refer following Figure
20. Write a program in C++ to overload unary ‘--’ operator to decrease value of data member of
class.
21. Write a program in C++ to overload unary ‘++’ operator to increase value of data member of
class.
22. Write a program in C++ to overload unary ‘-’ operator to negate values of data members of
class.
23. Write a program in C++ to overload unary ‘+’ operator to concatenate two strings.
24. Write a C++ program to declare a class product with members as product_no and name. Accept
and display data for one object of product. Use pointer to object to call functions of class.
25. Write a C++ program to declare a class employee with members as employee_no and name.
Accept the information for 5 objects and display it using pointer to array of objects.
26. Write a C++ program to write ‘Welcome to First lecture’ in a file. Then read the data from file
and display it on screen.
27. Write a C++ program to copy content of one file to another file.
28. Write a C++ program to calculate number of words in the “abc.txt” file.
29. Write a program to define add() function to add two integers and to add three integers.
30. Write a program to overload ‘+‘ operator to add two time objects having data members as
hours and minutes. Display the result using third object.