Practice ANS OOP
Practice ANS OOP
Questions:
1. List different access specifiers used in Inheritance and Describe use of private access
specifier used in the class.
Use:- If private access specifier is used while creating a class, then the public and protected
data members of the base class become the private member of the derived class and private
member of base class remains private.
2. List different access specifiers used in Inheritance and Describe use of protected access
specifier used in the class.
Use:- If protected access specifier is used while deriving class then the public and protected
data members of the base class becomes the protected member of the derived class and
private member of the base class are inaccessible.
3. List different access specifiers used in Inheritance and Describe use of public access
specifier used in the class.
Use:- If public access specifier is used while deriving class then the public data members of the
base class becomes the public member of the derived class and protected members becomes
the protected in the derived class but the private members of the base class are inaccessible.
4. Define multilevel inheritance. Draw the diagram to show multilevel inheritance. using
classes with data member and member function.
Deine:- the process of deriving a class from another derived class. When one class inherits
another class it is further inherited by another class. It is known as multi-level inheritance.
5. Define multiple inheritance. Draw the diagram to show multiple inheritance. using
classes with data member and member function.
Define:- Multiple Inheritance is a feature of C++ where a class can inherit from more than one
classes. The constructors of inherited classes are called in the same order in which they are
inherited.
//outside class
Using arithmetic operations on a number changes its value, likewise using arithmetic operation on
pointer changes the address value. The change in the address value depends on the size of the pointer
type and the type of arithmetic operation. Incrementing (++) or Decrementing (–) Pointers
Incrementing a pointer increases the stored address by the size of its type.
11. Write the use of following w.r.t file ios : : trunc and ios : : app open() and close() ios : :
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.
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.