Header Ads Widget

assignment-1 Object Oriented Programming 3341602

if you want hand written note then comment below your whatsapp no , i will forward it.



 Object Oriented Programming


Assignment-1                                  Sub:- OOP



Q.1 Explain object oriented programming and procedure oriented programming with features.

=>> Procedure oriented programming :-a POP instructs the computer ,step by step what to do.

procedure program unit includes the main block, subroutines functions procedures, file stopping ; includes module; libraries.

we can use english words for variable names and for statement also .

because of this feature we can use and read program easily.

when you run object code it makes executable code and you see the output of your program by executing the executable code.

Object oriented programming : OOP is an approach of creating classes for both data and functions that can be used as templates for creating objects on demands .

thus an object is considered to store data and set of operations that can access that data.

the function of an object are called as member function.

the objects can communicate with each other by calling one another's member function.


Q.2 define the following term , objects, classes, data abstraction, encapsulation, inheritance, polymorphism, Dynamic binding, message passing.

==>> Class: A class is a collection of object of similar type it is a blue print of real world objects .
class is a description of objects behaviorit describe objects.

Objects: An object is an identifiable run-time entity with some characteristics and behavior  objects represents a physical or real world entity.

Data abstraction : The act of representing essential features without including the explanation is said to be data abstraction.

Encapsulation: The wrapping up of data and functions into a single unit called classes is known as Encapsulation.

Inheritance: The process of by which one class can inherits data of other class is called inheritance.

Polymorphism: Using polymorphism we can define several operations with the same name that can do diffrent things in related classes. 

Dynamic Binding: The association of object with property or method occurs during run-time, rather than at compile time is called as Dynamic Binding.

Message Passing: The object communicate with one another by sending and receiving messages establishing communication among objects is called as message passing. 

Q.3 List out advantages of objects oriented programming. 

==>> User defines data types can be easily constructed .

data security is enforced using encapsulation.

existing code can be reused in other applications by means of inheritance.

OOP offers better maintainability of code. 

it also promises greater programmer productivity. better quality of software and lesser maintenance cost.

Object Oriented systems can be easily upgraded from small to large systems.

It is easy to partition the work in a project based to objects.

with OOP software complexity can be easily managed .

Q.4 List out applications of object oriented programming .

==>> OOP is used in graphical user interface design such as windows. hundreds of windowing  systems have been developed using the OOP techniques. 

OOP is used in simulations and modeling very often.

OOP is useful in development of complex real business systems. having numerous objects with complicated attributes and methods.

OOP is used in AI, expert systems, neural networks, and parallel programming.

Most CIM/CAM/CAD systems are developed using OOP.


Q.5 What is c++ ? write structure of c++ program and explain with suitable example.

==>>  c++ is an object oriented programming language.

it was developed by Bjarne stroustrup at Bell laboratories in USA.

it is also called as extension of C.

Structure :- 

#include<iostream>
using namespace std;

int main()
{
          cout<<"hello viewers"; 
return 0;
}

Example:-

#include<iostream>
using namespace std;
int main()
{
int a;
cout<<"enter your age";
cin>>a;
cout<<"age is ="<<a;

return 0;
}

Q.6 what is reference variable ? Explain with example.

==>>  Reference is on alias or another name or synonym for a variable having same value as its parent variable.

Example:-

#include<iostream> 
int main()
{
int a;
clrscr;
int &a=a;
cout<<"enter a =";
cin>>a;
cout<<"\n value of a is"<<a;
cout<<"\n value of r is"<<r;

r=r+10;
cout<<"\n now value of a is"<<a;
cout<<"\n now value of r is"<<r;

return 0;
}

Q.7 Explain scope resolution operator and manipulator ?

==>> scope of a variable is that region of the program where it can be used.

when two or more variable are defined in different blocks of program then local variables have precedence over global ones.

C++ provides a scope resolution operator with this operator local variable names can be distinguished from global names .

Example:-

#include<iostream>
double a=123;
int main()
{
double a = 3456;
cout<<"local a is "<<a;
cout<<"global a is "<<::a;

return 0;
}

Manipulators:-- It is used to format the data display on the screen .

the most commons are (1) endl   (2)  setw

Example:-- 

int main()
{
int m=1234, n=12, p=5;
clrscr;
cout<<"m= "<<setw(4)<<m<<endl;
cout<<"n= "<<setw(4)<<n<<endl;
cout<<"p= "<<setw(4)<<p<<endl;

return 0;
}


Q.8 Explain use of new and delete operator by example

==>> 
New operator :- The new operator can be used to create objects for any type.

syntax of new operator is  pointer variable = new data type;

here pointer variable is a pointer of type data type .

The new operator allocator memory  to hold a data object of type data type and returns address of the object.

Example:-
void main()
{
int *p;
p=new int;
cout<<"p="<<p;
*p =25;
cout<<"\n value pointed by p ="<<*p;
getch();
}

Delete operator :- when a data object no longer needed, it is destroyed to release the memory space for reuse in C++ for performing this task delete operator is used.

Example :- 

void main()
{
int *p;
p=new int;
cout<<"p="<<p;
*p =25;
cout<<"\n value="<<*p;
delete p;
getch();
}



Q.9 Explain Enum data type with example

=>> It provides a way for ataching names to the numbers defining symbolic constants.
Example :- 

enum color{red, blue, green}
int a = red.
























Post a Comment

1 Comments