Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: Object Oriented Programming Questions
Description: Here are few questions of OOPS for Students who study computer sciences as compulsory or optional subject at BS levels. Notes that match the Students level of concepts !

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


BS COMPUTER SCIENCE
SUBJECT

:

OOPS

Section A
Question 1(a):
Answer:
Template :
Template are the mechanism by which c++ implement genetic concept
...

Template is a blue print or formula for creating a generic class or function
...
class template is
an alternative of function overloading as once class is declared it can be used for different data types
to have a various related result
...


Syntax:
template < class T1, class T2,
...


:

DESTRUCTOR
Destructor is a special
member of a class used to
deallocate memory for a
class
...

to execute some code at the
time of it destruction
...


They are called in reverse
order
...


The memory deallocate by
destructor can be further
located at the other resources
used in the program
...


There is always a single
destructor in a class
...


It can not be overloaded
...


Destructor have the same
name as the class but have
a tild (~) symbol in a name
...
e c++ and
high level language i
...


Destructors are not supported
in Java
...


Destructors have no
parameters or arguments as
it only deallocate memory for
an object
...


It has no such concept
...
The return address is located where subroutine was called
...
It terminate the execution of the function and transfer the
control back to the calling function (or to the operating system if transfer control from main()
...
It return value for only void
function for non void function it may or may not return value
...
#include 2
...

4
...
{
6
...
Public:
8
...
{
10
...
Cout<<” constructor \n”;
12
...
}
14
...
{ 16
...
Cout<<”Destructor \n”;
18
...

20
...
Int main()
22
...
Method m();
24
...
}
26
...

Question 1(b):
Answer :
Difference Between Class and Object :

Class
1
...
e object
...
object is an instance of class
helps programmers to used
variables and methods inside
class
...
Class once created ,it does not 2
...

allocate memory space to store
values
...
It is declared using keyword
class
...
It is declared using keyword
new
...
Cass is used to bind data as
well as methods in a single
unit
...
Object is a variable of class
...
Class have logical exsistance 5
...

used for some special purpose
...
The new class inherit all the behavior of the original class
...

Derived class:
The new class that inherit the properties and functions of the existing class is known as Derived
class or child class
...
The basic principle of
inheritance is that each subclass share common properties with the class from which it is derived
...

2
...

4
...
Reusebillity:
Inheritance allows the developers to reuse the existing code in many situations
...
Saves Time And Efferts:
Inheritance saves a lot of time and effort to write the same classes again
...

3
...
This class can be used in a new application
without compiling it again
...


Program:
1
...
using namespace std;
3
...
o(); B
...
This operator has
many uses in c++
...

Uses:
Scope Resolution Operator is used for:
1
...

2
...

3
...

4
...


5
...

6
...

Program:
1
...

3
...
int main()
5
...
Int num=2;
7
...
std::Cout<<”local variable=”<<::num;
9
...
In Hierarchical inheritance all the features that are common in derived classes are
included in the base class
...

}
Class first_derived_class : public base _class{

...

}
Class third _derived_class: public base_class{

...
All derived classes have there own members as well as there base class
members
...

Program using Hierarchical Inheritance:

//Hierarchical inheritance
1
...

using namespace std;
3
...
class A //single base class
5
...
Public:
7
...
void getdata()
9
...

11
...

13
...

15
...

17
...

19
...

}
22
...

24
...

26
...

28
...

31
...

33
...

35
...


};
class C: public A // derived from base class A
{
public :
void sum()
{
cout<<”\n the sum of X and Y is :”< ...
void subtrction()
37
...

39
...

41
...
};
43
...
int main()
45
...
C obj1; //object of derived class C
47
...
D obj3;//object of derived class D 49
...
obj1
...
obj1
...
obj2
...
obj2
...
obj3
...
obj3
...

57
...

59
...

Function Overriding allows the user to use same name for calling the member function of
different class
...
However, the function of base class can be accessed by using
scope resolution operator
...


Program:
1
...
using namespace std;
3
...
{
5
...
void display()
7
...
cout<<”Function of parent class”;
9
...
};
11
...
{
13
...
void display()
15
...
cout<<”function of derived class”;

17
...
};
19
...
{
22
...
obj
...
return 0;
25
...
The
derived class can access the public, protected and private member of base class but the object
of derived class can not access the public , private and protected members of the base class
...
#include
2
...
Class parent 4
...

6
...
Int a; 8
...
Int b;
10
...
Int c;
12
...
};
14
...
{
16
...
Void in()
18
...
Cout<<”Enter a”;
20
...
Cout<<”Enter b”;
22
...
{
24
...
{ 26
...
Cout<<”a=”< ...
}

30
...

32
...
{
34
...
Obj
...
Obj
...
getch() 38
...
}

Question 1(j):
Answer:
DIFFERENCE BETWEEN USER DEFINED FUNCTION AND BUILT IN FUNCTION:
User Defined Function

Built in Function

1
...


1
...


2
...


2
...


3
...


3
...


4
...
e
main()
...
Execution does not begin from
these functions
...
User can change the name of
the user defined functions
...
Name once given to a function
by the developer cannot be
changed by the user
...
User defined these functions
to perform there required
specific task
...
The tasks these to perform are
decided by the system or
developer we can say
...
#include
2
...
//declaration of user defined
function 4
...
{
6
...
int main()
8
...
greet();//calling function
10
...
return 0;
12
...
#include
2
...
#include
4
...
{
6
...
number=36;
8
...

10
...
return 0;}

Examples:
Name() etc
...

SECTION B

Question 3:

Answer

:

Constructor:
The member function that can have the same name as the class name is called constructor
...
Constructor has no return type that mean it
cannot return any value
...


Constructor Overloading:
The process of declaring multiple constructor with same name but different parameter is known
as Constructor Overloading
Title: Object Oriented Programming Questions
Description: Here are few questions of OOPS for Students who study computer sciences as compulsory or optional subject at BS levels. Notes that match the Students level of concepts !