Object Oriented Programming - Unit Wise Questions
1. What is object oriented programming? Explain objects, class, encapsulation, data hiding, inheritance, and polymorphism.
1. Discuss the feature of the Object-Oriented Programming. Differentiate between Object Oriented Programming and Procedural Oriented Programming.
1. What are the main features of the Object-Oriented Programming? Explain with suitable practical examples.
1. Why do we need object oriented programming? How can we use inheritance to reuse already written and tested code in programs? Discuss with suitable example. (3+3+4)
1. Differentiate between structural programming approach and object oriented programming approach. Explain the inheritance, polymorphism with example.
1. Write any four features of object-oriented programming. Differentiate between operator overloading and function overloading.
1. Explain the object oriented programming with its advantages. What are the features of object oriented languages? Explain.
1. Discuss the feature of Object-Oriented Programming. Differentiate between Object Oriented Programming and any other programming language that you know.
1. What is object-oriented approach? How is it different from structured programming approach? Discuss the features of object-oriented languages in detail.
1. Write down the features of object oriented programming language and explain.
1. Explain in detail the following principles of Object-Oriented Programming.
i. Data encapsulation and data hiding. ii. Inheritance and polymorphism. iii. Abstraction
4. Explain abstraction with example.
4. What is structured programming? Discuss characteristics and problems associated with structured programming.
4. How object oriented programming differs from object based programming language? Discuss benefits of OOP.
11. How can we define our functions inside the namespace and use them outside?
2. How can you convert the user defined data type into primitive data type and vice versa? Explain both conversion routine with suitable example.
2. Why do we need the preprocessor directive # include < io stream >? Describe the major parts of a C++ program.
3. What do you mean by overloading of a function? When do we use this concept? Explain with example.
3. What is function overloading? How is it different from function overriding? Write a program that gives an example of function overriding.
3. Why data conversion is needed? Write a program to convert kilogram into gram using user define to user define data conversion.(1 kg = 1000 gm).
4. Explain the purpose of a namespace with suitable example.
5. What is the principle reason for passing arguments by reference? Explain with suitable code.
4. Explain the do while structure.
4. What is type casting? Explain with suitable example.
5. What is function overloading? Explain with suitable example.
5. Explain the inline function with example.
5. Explain with example of an inline function.
5. What is library function? How is it different from user defined function?
5. Explain do/while structure with example.
5. What is function overloading ? Explain with example.
6. What is library function? How is it different from user defined function?
6. Why type conversion is necessary in OOP? Explain with example, the type conversion routine.
6. Discuss relationship between pointers and arrays.
6. Explain the Inline function with example.
7. Explain about this pointer with suitable example.
5. What is the use of new and delete operators? Illustrate with example. What are advantages of new malloc.
6. What is meant by pass by reference? How can we pass arguments by reference by using reference variable? Illustrate with example.
7. Differentiate between structure and class in terms of access modifier
7. Explain the use of inline function with example.
7. Discuss the use of inline function with example.
5. What is the principle reason for using default arguments in the function? Explain how missing arguments and default arguments are handled by the function simultaneously?
6. What is meant by return by reference? How can we return values by reference by using reference variable? Illustrate with examples.
6."An overloaded function appears to perform different activities depending the kind of data send to it" Justify the statement with appropriate example.
9. Differentiate between overriding vs overloading.
9. Differentiate between macro and function.
9. Explain with example, how you create space for array of object using pointers?
8. What is this pointer? How can we use it for name conflict resolution?Illustrate with example.
10. Explain the use of break and continue statements in switch case statements in C++.
11. Write a program to demonstrate the use of default argument in functions.
11. Explain the different storage classes in C++.
12. How can you differentiate a macro with an inline function? Are they same or different? Justify.
13. What are the major differences between overriding and overloading?
1. Write a program according to the specification given below:
- Create a class Account with data members acc no, balance, and min_balance(static)
- Include methods for reading and displaying values of objects
- Define static member function to display min_balance
-Create array of objects to store data of 5 accounts and read and display values of each object
2. Why constructor and destructor are required on Object Oriented Programming? Explain with suitable example.
2. Discuss features of class and object. Design a class to represent a bank account with data members name, account-number, account-type, and balance and functions to assign initial values, to deposit an amount, to withdraw an amount after checking balance, and to display the name and balance. (4+6)
2. What is constructor? Explain their types? Discuss user defined parameterized constructor with suitable example.
2. How is a member function of a class defined? Define friend function. What are the merits and demerits of using friend function? Explain.
2. Explain the role of constructor and destructor in Object-Oriented Programming. Discuss user defined parameterized constructor with suitable example.
1. Explain the concept of user-defined to user-defined data conversion rotine located in the destination class.
3. Create a class Stack with suitable data members and member functions to push and pop the elements of the stack. Add the exception when user tries to add item while the stack is full and when user tries to delete item while the stack is empty. Throw exception in both of the cases and handle these exception.
3. Define constructor, list some of the special properties of the constructor functions
4. What is constructor ? Write a program to demonstrate constructor overloading.
4. How can you classify objects? Why dynamic objects are needed?
4. Why dynamic object is needed? Explain with suitable example.
6. Why constructor is needed? Explain different types of constructors with example.
4. What do you mean by dynamic initialization of variables?
5. Explain about the importance of constructors and destructors with their execution sequence.
6. How is dynamic initialization of objects achieved?
7. What are the importance of destructors?
8. What is class? Differentiate it with object.
8. What are the characteristics of constructor?
8. What is constructor? Differentiate it with destructor.
7. What is constructor? Explain the concept of default and default copy with suitable example.
8. Explain the static class members with example.
9. Explain about accessing a member function outside a class with example.
9. How can you define a member function outside a class ? Explain with suitable example.
7. Explain the default action of the copy constructor. Write a suitable program that demonstrates the technique of overloading the copy constructor.
7. What is destructor? Write a program to show the destructor call such that it prints the message "memory is released".
9. Create a real scenario where static data members are useful. Explain with suitable example.
2. Explain operator overloading. Write a program that overloads insertion and extraction operators.
2. Write a program to overload the unary minus operator using friend function.
2. What is meant by type conversion? Define two way of converting one user defined data type (object) to another user defined object? Write a program that converts object of another distance class with data members feet and inch.(Assume 1m = 3.3 feet and 1cm = 0.4 inch)
2. Explain the concept of operator overloading? List the operators that cannot be overloaded. Write programs to add two object of distance class with data members feet and inch by using by using member function and friend function.
3. What is operator overloading? What are the benefits of operator overloading? How is operator overloading different from function overloading. Write a program that shows an example of function overloading. (2+2+2+4)
7. Write a program that illustrates the conversions between objects of different classes having conversion function in source object.
5. Write a program to compute subtraction of two complex numbers using operator overloading.
5. What is operator overloading? Explain their types with suitable examples.
8. What is an operator function? Explain with syntax.
10. Write a program that increases an integer value by 1 (one) overloading + + operator.
10. Explain the role of operator overloading with example.
2. How can we use inheritance for code reusability? Discuss multiple inheritance with suitable example.
1. Write a program according to the specification given below:
- Create a class Teacher with data members tid & subject and ember functions for reading and displaying data members.
- Create another class Staff with data members sid & position, and member function for reading and displaying data members.
- Derive a class Coordinator from Teacher and Staff and the class must have its own data member department and member functions for reading and displaying data members.
- Create two object of Coordinator class and read and display their details.
2. Differentiate between single inheritance and multiple inheritance? Imagine a college hires some lectures. Some lectures are paid in period basic, while others are paid in month basic. Create a class called lecture that stores ID and name of lectures. From this class derive two classes: part time, which adds payperhr(type float): and full time, which adds paypermonth(type float). Each of these three classes should have a readdata() function to get its data from user at the key board and printdata() function to display the data.
Write a main() program to test the Full time and Part time classes by creating instance of them asking the user to fill their data with readdata () and display the data with printdata().
3. What is inheritance? Explain the ambiguities associated with multiple inheritance with suitable example programs.
2. Depict the difference between private and public derivation. Explain derived class constructor with suitable program.
3. How ambiguity arises in multipath inheritance? How can you remove this type of ambiguity? Explain with suitable example.
3. Define a student class (with necessary constructors and member functions) in Object Oriented Programming (abstract necessary attributes and their types). (Write a complete code in C++ programming language).
• Derive a computer Science and Mathematics class from student class adding necessary attributes (at least three subjects).
• Use these classes in a main function and display the average marks of computer science and mathematics students.
3. Define a clock class (with necessary constructors and member functions) in Object Oriented Programming (abstract necessary attributes and their types). (Write a complete code in C++ programming language).
- Derive a wall_clock class from clock class adding necessary attributes.
- Create two objects of wall_clock class with all initial state to 0 or NULL.
3. Define a Shape class (with necessary constructors and member functions) in Object-Oriented Programming (abstract necessary attributes and their types). (Write a complete code in C++ programming language)
• Derive Triangle and Rectangle classes from Shape class adding necessary attributes.
• Use these classes in a main function and display the area of triangle and rectangle.
3. Explain the role of inheritance in object oriented programming. What is public, private and protected dentation? Explain.
4. Explain the syntax and rules of multiple inheritance in C++ with example.
8. Explain the difference between private and public inheritance with suitable diagram.
7. Differentiate between super class and sub class with suitable examples.
7. What is Inheritance? Explain their types with their suitable examples.
7. What is multiple inheritance? Explain with example.
7. What is the role of protected access specifies in inheritance ? Explain with example.
7. Differentiate between base class and derived class with suitable examples.
8. Differntiate between private, public and protected variable with suitable example.
8. Briefly explain types of inheritance used in object oriented Programming.
10. What is container class? Differentiate container class from inheritance.
12. Explain the multilevel inheritance. How is it different from multiple inheritance?
12. Write short notes on:
a. Manipulators
b. Protected Access Specifier
3. Explain types of polymorphism briefly. Write down roles of polymorphism. How can we achieve dynamic polymorphism briefly. Write down foles of polymorphism. How can we achieve dynamic polymorphism? Explain with example.
4. Display polymorphism with example.
4. "Concept of friend in against the philosophy of Object Oriented Programming". Explain.
6. What is virtual function? Explain.
9. Why friend function is required? Discuss with example.
10. How late binding is different from early binding. Write a program that explains late binding using virtual function.
8. What is friend function? Why it is used in OOP? Explain with an example.
8. Differentiate between virtual function and pure virtual function.
9. Differentiate between compile time polymorphism and run time polymorphism.
9. What is container class? Differentiate container class from inheritance.
8. What is the concept of friend function? How it violates the data hiding principle? Justify with example.
9. Differentiate container class from inheritance. Explain with suitable example.
9. What is abstract base class? Give an example.
9. Differentiate between function overriding and function overloading. Explain with suitable example.
10. Explain the role of polymorphism in Object Oriented Programming.
10. Explain the role of polymorphism in Object Oriented Programming.
11. Explain about “this” pointer with suitable example.
11. What is friend function? Write a program to multiply any two private numbers of two different classes using friend function.
13. Explain the friend function with its syntax.
6. What is template? How can you differentiate a function template from a class template? Explain.
6. Write a C++ program containing a possible exception. Use a try block to throw it and a catch block to handle it properly.
6. Why exception handling is required? Explain with suitable example.
8. Write a C++ program containing a possible exception. Use a try block to throw it and a catch block to handle it.
11. Why do we need exceptions? Explain “exceptions with arguments” with suitable program.
9. What is exception? Why exception handling is better to use? Explain exception handling with try..... catch by using suitable example.
10. Explain the function templates with example.
11. Differentiate between overloaded functions and function templates.
11. Discuss importance of template. Write syntax of function template.
9. How can you define catch statement that can catch any type of exception? Illustrate the use of multiple catch statement with example.
10. When class templates are useful? How can you define a class that can implement stack with integer as well as sack of strings? Illustrate with example.
12. Discuss different keywords used in exception handling.
10. Create a function called swaps() that interchanges the values of the two arguments sent to it (pass these arguments by reference). Make the function into a template, so it can be used with all numerical data types (char, int, float, and so on). Write a main() program to exercise the function with several types.
12. What are the main advantages of using exception handling mechanism in a program?
12. Define try, throw and catch statement in C++ with example.
11. Explain how exceptions are used for handling C++ error in a systematic and OOP-oriented way with the design that includes multiple exceptions.
13. Differentiate between class template and function template.
13. Explain the exceptional handling with example.
3. Briefly explain the hierarchy of stream classes. Write a program that overloads extraction and insertion operators.
5. Discuss input and output with C in and C out respectively.
4. Write a member function called reverseit() that reverses a string ( an array of character). Use a for loop that swaps the first and last characters, then the second and next-to last characters and so on. The string should be passed to reverseit() as an argument.
5. What is the use of get and getline functions? Explain with suitable example.
8. Write a program in C++ to count a number of words in a line of text.
12. What are the advantages of using the stream classes for I/O? Write a program that writes object to a file.
10. Explain the features of I/O system supported by C++.
10. Which functions can be used for reading and writing object? Describe briefly. Write a program that read values of two objects of student class(assume data members are sid , sname, and level) and display the data in monitor.
11. What is meant by stream? Write a program that reads content of file data.txt and displays the content in monitor.
12. Write the syntax and use of get line () and write () functions.
12. Write short notes on:
- Cascading of IO operators
- Pure Virtual Function
12. How is character I/O different from Binary I/O? Explain with examples.