PERI INSTITUTE OF TECCHNOLOGY                                 MANNIVAKKAM, CHENNAI-48                     DEPARTMENT OF CO...
7.   What is virtual base class? Give an example.     A class which is defined as virtual at the time of inheriting it. Th...
PART B                           ( 5 X 16 = 80 )11. (a) Explain the basic concepts of oops with suitable Examples         ...
Inheritance: One of the most useful aspects of object-oriented programming is code reusability. As the namesuggests Inheri...
(b) .Write a C++ program to construct student mark list for three subjects.      Write the program to display name, rollno...
12. (a) Write a program to create a class “EMPLOYEE” with data members emp_name ,emp_id,       emp_dept, basicpay, PF,gros...
EMPLOYEE emp[10];int i,n;clrscr();cout<<"Enter the no.of employees:";cin>>n;for(i=1;i<=n;i++) {   emp[i].input();   emp[i]...
12.   (a) What is operator overloading? What are its types? Explain the types with Example      Programs.(16)
Or
(b) Explain in detail about type conversion and its three cases.   (16)Example:
14.   (a) what is template ?. Explain type of template with suitable example   (16)Type of Template:   i) class template  ...
Example:           Or
(b) What are the types of inheritance? Explain about Multiple inheritances with example.   (16)
Example:
15. (a) Explain the Exception Handling mechanism available in C++ with suitable examples.   (16)
Or
(b) (i) What is file handling? Explain with example program   (8)
(ii) Explain following Formatted I/O function with Example.             1)width() 2) precision() 3) fill() 4)setf() 5) uns...
iv)v) Unsetf() Clear the flag specified by the arg1,arg2 of setf( ) function
EEE 3rd year  oops cat 3  ans
EEE 3rd year  oops cat 3  ans
EEE 3rd year  oops cat 3  ans
EEE 3rd year  oops cat 3  ans
Upcoming SlideShare
Loading in …5
×

EEE 3rd year oops cat 3 ans

1,342 views
1,162 views

Published on

Object Oriented programming

2 Comments
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total views
1,342
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
39
Comments
2
Likes
0
Embeds 0
No embeds

No notes for slide

EEE 3rd year oops cat 3 ans

  1. 1. PERI INSTITUTE OF TECCHNOLOGY MANNIVAKKAM, CHENNAI-48 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING CONTINUOUS ASSESMENT TEST-3 CS2311 - OBJECT-ORIENTED PROGRAMMINGClass: III / EEE Date:Semester: V Duration: 180 Min. Max. Marks: 100 PART A (10 X 2 = 20 )1. Define class and object. Ans: Class is a collection of similar object, it’s an aggregation of data members and function member.Ex: fruit mangoObjects are the basic runtime entities, ex: place, person2. What is the function overloading? Give an example. Ans: More than one functions with same name but with different set of arguments. This is known as functionoverloading Ex: add(int a, int b); add(float b, float c);3. Define copy constructor Ans: When one object is copied to another using initialization they are copied by executing the copyconstructor. Ex: integer(integer &i);4. Define multiple inheritances. Ans: The inheritance where the derived class is derived from more than one base class.5. What are all types of type conversions? Ans: a. Implicit Type conversion, b. Built-in Data type to an Object, c. object to Built-in Data type, d. Object to Object6. What is the need for function templates? How are they created? Function template is used create a family of function with different argument (generic function).
  2. 2. 7. What is virtual base class? Give an example. A class which is defined as virtual at the time of inheriting it. The complier takes a note of it and when it is inherited further using multiple inheritance, it ensures that only one copy of the sub object of the virtual inherited class exists in the derived class. class L { /* ... */ }; // indirect base class class B1 : virtual public L { /* ... */ }; class B2 : virtual public L { /* ... */ }; class D : public B1, public B2 { /* ... */ }; // valid8. How is an exception handled in C++?9. Define a Namespaces. Ans: An enclosure of logical nature which helps libraries to have separate existence and solves the name conflict problemEx: using namespace std;10. Define Java Virtual Machine (JVM).Ans: Java virtual machine (JVM) is a virtual machine that can execute Java bytecode. It is the code executioncomponent of the Java software platform
  3. 3. PART B ( 5 X 16 = 80 )11. (a) Explain the basic concepts of oops with suitable Examples (16) Ans: Object oriented programming concepts: i) objects ii) classes iii) methods and messages iv) abstraction and encapsulation v) inheritance vi) abstract classes Polymorphism Class: When you define a class, you define a blueprint for an object. This doesnt actually define any data, but it does define what the class name means, that is, what an object of the class will consist of and what operations can be performed on such an object. Method and Message: Method is function, it is used for communicating between object, message is use to command the functionality behavior of object. Abstract class: Class with no object is known as abstract class
  4. 4. Inheritance: One of the most useful aspects of object-oriented programming is code reusability. As the namesuggests Inheritance is the process of forming a new class from an existing class that is from the existing classcalled as base class, new class is formed called as derived class. This is a very important concept of object orientedprogramming since this feature helps to reduce the code sizePolymorphism: The ability to use an operator or function in different ways in other words giving differentmeaning or functions to the operators or functions is called polymorphism. Poly refers many. That is a singlefunction or an operator functioning in many ways different upon the usage is called polymorphism. Or
  5. 5. (b) .Write a C++ program to construct student mark list for three subjects. Write the program to display name, rollno,marks,avg and total. Use class and objects (16)
  6. 6. 12. (a) Write a program to create a class “EMPLOYEE” with data members emp_name ,emp_id, emp_dept, basicpay, PF,gross_pay ,net_pay, store them in an array of objects. Input the total number if employees and perform the following: (i) Calculate the Gross pay and Net pay. (ii) Display the employee’s details with salary. (16) #include<iostream.h> #include<string.h> #include<conio.h> class EMPLOYEE { int empid; char name[10]; char dept[10]; int bp,hra; float gp,np; int pf; public: void input(); void show(); void pay(int bp,int pf,int hra); }; void EMPLOYEE::input() { std::cout<<"nEnter empid:"; std::cin>>empid; cout<<"Enter employee name:"; cin>>name; cout<<"Enter department:"; cin>>dept; cout<<"Enter basic pay:"; cin>>bp; cout<<"Enter hra:"; cin>>hra; cout<<"Enter pf:"; cin>>pf; } void EMPLOYEE::show() { cout<<"nn"; cout<<"nEmployee id is: "<<empid; cout<<"nEmployee name: "<<name; cout<<"nDepartment: "<<dept; pay(bp,pf,hra); } void EMPLOYEE::pay(int bp,int pf,int hra) { gp=bp+hra; np=gp-pf; cout<<"nGross Pay is: "<<gp; cout<<"nNet Pay is: "<<np; } void main() {
  7. 7. EMPLOYEE emp[10];int i,n;clrscr();cout<<"Enter the no.of employees:";cin>>n;for(i=1;i<=n;i++) { emp[i].input(); emp[i].show(); } getch();} Or (b) Explain the constructor concept with its types with example programs. (16)
  8. 8. 12. (a) What is operator overloading? What are its types? Explain the types with Example Programs.(16)
  9. 9. Or
  10. 10. (b) Explain in detail about type conversion and its three cases. (16)Example:
  11. 11. 14. (a) what is template ?. Explain type of template with suitable example (16)Type of Template: i) class template ii) Function TemplateClass Template:Example:
  12. 12. Example: Or
  13. 13. (b) What are the types of inheritance? Explain about Multiple inheritances with example. (16)
  14. 14. Example:
  15. 15. 15. (a) Explain the Exception Handling mechanism available in C++ with suitable examples. (16)
  16. 16. Or
  17. 17. (b) (i) What is file handling? Explain with example program (8)
  18. 18. (ii) Explain following Formatted I/O function with Example. 1)width() 2) precision() 3) fill() 4)setf() 5) unsetf() (8)i)ii)iii)
  19. 19. iv)v) Unsetf() Clear the flag specified by the arg1,arg2 of setf( ) function

×