Object Oriented Programming Using C++'

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Object Oriented Programming using ‘C++’

Chapter 1

1) State the use of cin and cout.

2) State use of scope resolution operator.

3) State any four object oriented languages.

4) State the difference between OOP and POP.

5) Write a ‘C++’ program to find factorial of given number using loop.

6) Describe following terms: Inheritance, data abstraction, data encapsulation, dynamic binding

7) (i) Describe structure of C++ program with diagram.


(ii) Write a C++ program to add two 3 × 3 matrices and display addition.

8) Write any four benefits of OOP.

9) Write the applications of object oriented programming.

10) Write a program to sort an 1-d array in ascending order.

11)Give output for following code:


class student
{
int roll no;
char name [14];
} s[6];
void main( )
{
cout <<sizeof(s);
}

12) Write a C++ program to accept array of five elements, find and display smallest number from an
array.
13) With suitable diagram describe structure of C++ program.
14) Write a C++ program to print multiplication table of 7.(example: 7 × 1 = 7 ..... 7 × 10 = 70)
15) a.Write a C++ program to find whether the entered number is even or odd.
b.Write a C++ program to declare a structure employee with members as empid and emp name.
Accept and display data for one employee using structure variable.
Chapter2

1) Define class and object


2) Describe use of protected access specifier used in the class.
3) What is a class? Give its example.
4) Describe use of static data member with example.
5) Describe derived class with example.

6) Describe memory allocation for objects.

7) Write two properties of static member function.

8) Explain the friend function with proper example.

9) Write a C++ program to find smallest number from two numbers using friend function. (Hint : use two
classes).

10)Write a C++ program to create a class STUDENT The data members of STUDENT class.

Roll_No
Name
Marks

Accept data for five students and display it. Write a C++ program to displya sum of array elements of
array size n:

11) Describe how memory is allocated to objects of class with suitable diagram.

12) Differentiate between contractor and destructor

13) Write a C++ program to declare a class student with members as roll no, name and department.
Declare a parameterised constructor with default value for department as ‘CO’ to initialize members of
object. Initialize and display data for two students.

14) State the rules for writing destructor function.

15) Write a program to declare a class ‘student’ having data members as ‘stud_name’ and ‘roll_no’.
Accept and display this data for 5 students.

16) Write a C++ program to declare a class ‘circle’ with data members as radius and area. Declare a
function getdata to accept radius and putdata to calculate and display area of circle.

17)Write a C++ program to declare a class addition with data members as x and y. Initialize value of x and
y with constructor. Calculate addition and display it using function ‘display.’
18) Write a C++ program to find greatest number among two numbers from two different classes using
friend function.
19) Write a C++ program to declare a class ‘Account’ with data members as accno, name and bal. Accept
data for eight accounts and display details of accounts having balance less than 10,000.
Chapter3

1) Explain virtual base class with suitable example.

2) What is inheritance? Give different types of inheritance.

3) Describe the concept of virtual base class with suitable example.


4) Write any two characteristics of destructor.

5) Write a program to implement single inheritance from the

class :employee variables: emp_id,name

class :emp-info variable:basic-salary

6)Write a C++ program to declare a class COLLEGE with members as college code. Derive a new class
as STUDENT with members as studid. Accept and display details of student along with college for one
object of student.

7) What is multilevel inheritance? Draw the diagram to showmultilevel inheritance. using classes with
data member and member function.

8)Write a program to implement multiple inheritance as shown in following Figure No. 1

Class : Subject1 Class : Subject 2

data mem : m1 data mem : m2

Class : Result

data mem : Total

Accept and display data for one object of class result.


9) State and describe visibility modes and its effects used in inheritance.
10) Describe with example class, passing parameters to base class constructor and derived class
constructor by creating object of derived s

11)Write a C++ program to implement following in heritance. Refer Figure


Class : College Student

Data mem: student id ,

College_code

Class : test
Class : sports
data mem : percentage

data mem : grade

Class : Result

Accept and display data for one object of class result (Hint : use virtual base class).

12) What is parameterized constructor?

13)Write a program to implement the following hierarchy using suitable member functions.

Class :student
member: roll_no,name

Class: test Class: result


member : mark1,mark2 member: total

class:sports
member :score

14) Write syntax to define a derived class.


15) Write a C++ program to declare a class ‘College’ with data members as name and college code.
Derive a new class ‘student’ from the class college with data members as sname and roll no. Accept and
display details of one student with college data
16)Write a C++ program to implement inheritance shown in following figure:

Class : Teacher
Class : Student datamember :
datamember : Name sname rollno.
empid

Class : Info

Accept and display data of one teacher and one student using object of class ‘Info’.
17) Write a C++ program to implement following inheritance.

Class : Employee Data : empid


Member : empcode

Class : ProgrammerDatamember : Skill


Class : ManagerDatamember : department

Accept and display data for one programmer and one manager. Make display function virtual.

18)Write C++ program for following multilevel inheritance.

Class : Carmanufacturer datamember :


Name

Class : Carmodel datamember :


Model name, Model no.

Class : Car datamember : Car no.,


colour
Accept and display data for one car with all details.

Chapter4
1) Give meaning of following statements:

int * ptr, a = 5;
ptr = & a ;
cout << * ptr ;
cout << ( * ptr) + 1;

2) Differentiate between run time and compile time polymorphism.

3)(i) Write any three rules of operator overloading.


(ii) Write a program in C++ to overload unary ‘_’ operator to negate values of data members of class.

4) Write a program to swap two integers using call by reference method.

5) Describe ‘this’ pointer with an example.

6) What are the rules for virtual function?

7) Write a program to declare a class ‘book’ containing data members as ‘title’, ‘author-name’,
‘publication’, ‘price’. Accept and display the information for one object using pointer to that object.

8)With suitable example, describe effect of ++ and – – operators used with pointer in pointer arithmetic.
Write a C++ program to swap two integer numbers and swap two float numbers using function
overloading. (Hint : overload swap function)

7)Write a C++ program to overload binary operator ‘+’ to concatenate two strings.

Chapter5

1)Write the use of ios : : in and ios : : out.

2) Give syntax and use of fclose ( ) function.

3) Write a C++ program to count number of spaces in text file.

4) Write a C++ program to append data from abc . txt to xyz . txt file.

5) Write a program to count the number of lines in file.

6) Write a program that copies contents of one file into anotherfile.


7) Write a C++ program to count number of spaces present in contents of file.

8) Write a C++ program to write ‘Welcome to poly’ in a file.Then read the data from file and display it on
screen.

You might also like