You are on page 1of 2

Question Bank: Object Oriented Programming (9036)

Class: SYIF (Semester – III)


Chapter No. 02 Classes and Objects

Summer 2004 (Yearly Pattern): Marks=16


1. Describe following terms: 8
a. Object
b. Class
2. Define a class student, consisting of data members rollno, and name.
Write a member function accept( ) to accept values for this data. 8

Summer 2005 (Yearly Pattern): Marks=12


1. How to define a member function outside the body of class? 4
2. Write a main( ) function for following class to – 8
a. Create an object
b. Accept and display information for the same object.
class student
{
private: int roll;
char name[30];
public: void accept(void);
{
cout<<”Enter roll number:”;
cin>>roll;
cout<<”\nEnter name:”;
cin>>name;
}
void display(void)
{
cout<<”Name:”<<name<<”\n”;
cout<<”Roll:”<<roll<<”\n”;
}
};

Summer 2006 (Yearly Pattern): Marks=08


1. Find the errors if any, in the following code: 4
class data
{ private: int d1; float d2;
Public void data(); void display();}
void main()
{ data d;
d.display data();
}
2. Write a program to illustrate friend function. 4
Winter 2007 (Yearly Pattern): Marks=08
1. State properties of static member function of a class. 4
2. Find error if any in the following code: 4
class sample

-1-
{ int d1;
float d2;
public:
void data();
void putdata();
}
void main()
{ sample s;
s.data putdata();
return(0);
}
Winter 2007 (Semester Pattern): Marks=20
1. What is class? Give examples. 2
2. How memory is allocated when multiple objects of class are created?
Explain with suitable example. 2
3. Can we create object of one class in definition of another class?
Explain with suitable example. 4
4. Write a program to declare a class student containing data members
roll number, name and percentage of marks. Read data for two students
and display data of student having highest percentage. 4
5. Explain differences between structure and class with example 4
6. Find errors from following code and rectify the code: 4
class complex
{
int real, imaginary;
public:
void complex();
void Readdata();
void Showdata();
}
void main()
{
complex c1;
c1.Readdata();
c1.Displaydata();
}

Summer 2008 (Semester Pattern): Marks=20


1. Define a class with syntax. 2
2. How many ways we can define a member function in the class? Give its
syntax. 2
3. Write a program to declare a class rectangle having data members length
and breadth. Accept this data for one object and display area and perimeter
of rectangle. 8
4. Compare structure and class. 4
5. Describe memory allocation of objects. 4

-2-

You might also like