Untitled 1

what is oop ?
==-Object-oriented programming (OOP) is a programming language model in which programs are organized around data, or objects, rather than functions and logic 
== An object can be defined as a data field that has unique attributes and behavior.


Principles of OOP
==Object-oriented programming is based on the following principles

==Encapsulation- The implementation and state of each object are privately held inside a defined boundary, or class.
Other objects do not have access to this class or the authority to make changes but are only able to call a list of public functions, or methods. This characteristic of data hiding provides greater program security and avoids unintended data corruption.

==Abstraction- Objects only reveal internal mechanisms that are relevant for the use of other objects, hiding any unnecessary implementation code. This concept helps developers make changes and additions over time more easily.

==Inheritance- Relationships and subclasses between objects can be assigned, allowing developers to reuse a common logic while still maintaining a unique hierarchy. This property of OOP forces a more thorough data analysis, reduces development time and ensures a higher level of accuracy.

==Polymorphism- Objects are allowed to take on more than one form depending on the context. The program will determine which meaning or usage is necessary for each execution of that object, cutting down on the need to duplicate code.
Difference between OOP and POP:

1.it is Object oriented…….it is Structure oriented.
2.the Program is divided into objects. ……..the Program is divided into functions.
3.it is Bottom-up approach……it is Top-down approach.
4.Inheritance property is used…… here Inheritance is not allowed.
5.It uses access specifier……. It doesn’t use access specifier.
6.the Encapsulation is used to hide the data…………… there isNo data hiding.
7.Concept of virtual function is there ………there is No virtual function.
8.exp ,C++, Java…….. exp,C, Pascal.


Explain Basic Concepts of OOP. OR
Explain Following terms.
Various concepts present in OOP to make it more powerful, secure, reliable and easy.
 An object is an instance of a class.
 An object means anything from real world like as person, computer, bench etc…
 Every object has at least one unique identity.
 An object is a component of a program that knows how to interact with other pieces of the program.
 An object is the variable of the type class.
 For example, If water is class then river is object.
 A class is a template that specifies the attributes and behavior of things or objects.
 A class is a blueprint or prototype from which objects are created.
 A class is the implementation of an abstract data type (ADT).
 It defines attributes and methods.
class employee // Class
char name[10]; // Data member
int id; // Data member
void getdata() // Member function
cout<”enter name=”” and=”” id=”” of=”” employee:=”” ”;=””>”enter>

}a; // Object Declaration

 In above example class employee is created and ‘a’ is object of this class.
 Object declaration can be also done in main() function as follows:
int main()
employee a;

Data Abstraction
 Just represent essential features without including the background details.
 They encapsulate all the essential properties of the objects that are to be created.
 The attributes are sometimes called ‘Data members’ because they hold information.
 The functions that operate on these data are sometimes called ‘methods’ or ‘member functions’.
 It is used to implement in class to provide data security.
 Wrapping up of a data and functions into single unit is known as encapsulation.
 In C++ the data is not accessible to the outside world.
 Only those functions can access it which is wrapped together within single unit.
 Inheritance is the process, by which class can acquire the properties and methods of another class.
 The mechanism of deriving a new class from an old class is called inheritance.
 The new class is called derived class and old class is called base class.
 The derived class may have all the features of the base class.
 Programmer can add new features to the derived class.
 For example, Student is a base class and Result is derived class.
 -A Greek word Polymorphism means the ability to take more than one form.
- Polymorphism allows a single name to be used for more than one related purpose.
 -The concept of polymorphism is characterized by the idea of ‘one interface, multiple methods’,
 -That means using a generic interface for a group of related activities.
- The advantage of polymorphism is that it helps to reduce complexity by allowing one interface to specify a
general class of action’. It is the compiler’s job to select the specific action as it applies to each situation.
 It means ability of operators and functions to act differently in different situations.
int total(int, int);
int total(int, int, float);
==Static Binding
 Static Binding defines the properties of the variables at compile time. Therefore they can’t be changed.
==Dynamic Binding
 Dynamic Binding means linking of procedure call to the code to be executed in response to the call.
 It is also known as late binding, because It will not bind the code until the time of call at run time. In
other words properties of the variables are determined at runtimes.
 It is associated with polymorphism and inheritance.
==Message Passing
 A program contains set of object that communicates with each other.
 Basic steps to communicate
1. Creating classes that define objects and their behavior.
2. Creating objects from class definition
3. Establishing communication among objects.
 Message passing involves the object name, function name and the information to be sent.
==Example: employee.salary(name);
In above statement employee is an object. salary is message, and name isinformation to be sent.\

List out benefits of OOP.
   1.We can eliminate redundant code though inheritance.
   2.Saving development time and cost by using existing module.
3.Build secure program by data hiding.
 4.It. is easy to partition the work in a project based on object.
 5.it.ata centered design approach captures more details of a programming model.
 6.It .can be easily upgraded from small to large system.
 7.It is easy to map objects in the problem domain to those in the program.
 8.Through message passing interface between objects makes simpler description with external system.
 9.Software complexity can be easily managed.
4) List out Applications of OOP. 
  this are the maain applications of oop
1. Real-time systems
2. Simulation and modeling
3. Object oriented database
4. Artificial intelligence and expert systems
5. Neural networks and parallel programming
6. Decision support and office automation
7. CIM/CAM/CAD systems.
8. Distributed/Parallel/Heterogeneous computing
9. Data warehouse and Data mining/Web mining

question-why c++ is note pure OOP langusge or why it is called partial or semi Object Oriented Language:

 Main function is outside the class : C++ supports object-oriented programming, but OO is not intrinsic to the language. You can write a valid, well-coded, excellently-styled C++ program without using an object even once.

 Concept of Global variable : In C++, we can declare a variable globally, which can be accessible from anywhere and hence, it does not provides complete privacy to the data as no one can be restricted to access and modify those data and so, it provides encapsulation partially whereas In JAVA, we can declare variable inside class only and we can provide access specifier to it.

Availability of Friend function: Friend Class A friend class can access private and protected members of other class in which it is declared as friend. It is sometimes useful to allow a particular class to access private members of other class.
Therefore, again the Object oriented features can be violated by C++.

question –diferentiate c vs….. c++
1.C does no support polymorphism, encapsulation, and inheritance which means that C does not support object oriented programming……..C++ supports polymorphism, encapsulation, and inheritance because it is an object oriented programming language.
2.C is a subset of C++……..C++ is a superset of C.
3.C contains 32 keywords. …….C++ contains 52 keywords.
4.For the development of code, C supports procedural programming. …….C++ is known as hybrid language because C++ supports both procedural and object oriented programming paradigms.
5.Data and functions are separated in C because it is a procedural programming language. ……Data and functions are encapsulated together in form of an object in C++. 6.C does not support information hiding. Data is hidden by the Encapsulation to ensure that data structures and operators are used as intended.
7.Built-in data types is supported in C.. ……Built-in & user-defined data types is supported in C++.
8.is a function driven language because C is a procedural programming language. C++ is an object driven language because it is an object oriented programming.
9.unction and operator overloading is not supported in C. ……Function and operator overloading is supported by C++.
10.C is a function-driven language. …….C++ is an object-driven language


What is C++? Explain Structure of C++ Program.
~ C++ is an object oriented programming language.
~ It is a superset of C language and also called as extended version of C language.
~ It was developed by Bjarne Stroustrup at AT&T Bell lab in New Jersey, USA in the early 1980’s.
~ Structure of C++ program is as follow. 
                                                                                             Include Files 
                                                                                              Class Declaration or Definition
                                                                                              Member functions definitions 
                                                                                              Main function

~In any program first write header files like as iostream.h, conio.h, etc..as per requirement of program.
~After header file write class declaration or definition as per your planning.
~After class, define all member functions which are not define but declare inside the class.
~In last write main function without main function program execution is not possible.

#include //Header File
using namespace std;
class trial //Class
int a;
void getdata()
void putdata();
void trial::putdata() //Member Function outside class definition
cout<“the value=”” of=”” a=”<}
int main() //Main Function
trial T;
The value of a = 10

“the> Describe various operators used in C++.
An operator is a symbol that tells the compiler to perform certain mathematical or logical operation.

1. Arithmetic Operators
Arithmetic operators are used for mathematical calculation. C++ supports following arithmetic operators
+ Addition or unary plus
– Subtraction or unary minus
* Multiplication
/ Division
% Modulo division

 (note!!. make box on signs and than write its expression on right)

2. Relational Operators
Relational operators are used to compare two numbers and taking decisions based on their relation.
Relational expressions are used in decision statements such as if, for, while, etc…
< less> less>
<= less=”” than=”” or=”” equal=””>=>
> greater than
>= greater than or equal to
== is equal to
!= is not equal to
3. Logical Operators
Logical operators are used to test more than one condition and make decisions
&& logical AND (Both non zero then true, either is zero then
|| logical OR (Both zero then false, either is non zero then true)
! logical NOT (non zero then false, zero then true)
4. Assignment Operators
Assignment operators are used to assign the result of an expression to a variable. C++ also supports
shorthand assignment operators which simplify operation with assignment
= Assigns value of right side to left side
+= a += 1 is same as a = a + 1
-= a -= 1 is same as a = a – 1
*= a *= 1 is same as a = a * 1
/= a /= 1 is same as a = a / 1
%= a %= 1 is same as a = a % 1
5. Increment and Decrement Operators
These are special operators in C++ which are generally not found in other languages.
++ Increments value by 1.
a++ is postfix, the expression is evaluated first and then the value is incremented.
Ex. a=10; b=a++; after this statement, a= 11, b = 10.
++a is prefix, the value is incremented first and then the expression is evaluated.
Ex. a=10; b=++a; after this statement, a= 11, b = 11.
— Decrements value by 1.
a– is postfix, the expression is evaluated first and then the value is decremented.
Ex. a=10; b=a–; after this statement, a= 9, b = 10.
–a is prefix, the value is decremented first and then the expression is evaluated.
Ex. a=10; b=–a; after this statement, a= 9, b = 9.
6. Conditional Operator
A ternary operator is known as Conditional Operator.
exp1?exp2:exp3 if exp1 is true then execute exp2 otherwise exp3
Ex: x = (a>b)?a:b; which is same as
7. Bitwise Operators
Bitwise operators are used to perform operation bit by bit. Bitwise operators may not be applied to float
or double.
& bitwise AND
| bitwise OR
^ bitwise exclusive OR
< shift=”” left=”” (=”” shift=”” left=”” means=”” multiply=”” by=””>
>> shift right ( shift right means divide by 2)
8. Special Operators
& Address operator, it is used to determine address of the variable.
* Pointer operator, it is used to declare pointer variable and to get value from it.
, Comma operator. It is used to link the related expressions together.
sizeof It returns the number of bytes the operand occupies.
. member selection operator, used in structure.
-> member selection operator, used in pointer to structure.
9. Extraction operator (>>)
Extraction operator (>>) is used with cin to input data from keyboard.
10. Insertion operator (<>
Insertion operator (<) is=”” used=”” with=”” cout=”” to=”” output=”” data=”” from=””>)>
11. Scope resolution operator (::)
Scope resolution operator (::) is used to define the already declared member functions of the class.

Explain following terms in c++

— It defines a scope for the identifiers that are used in a program.
— For using identifiers defined in namespace using directive is used as follows:
using namespace std;
–std is the namespace where ANSI C++ standard class libraries are defined.
— All ANSI C++ programs must include this directive.
— This will bring all the identifiers defined in std to the current global scope.
— They are explicitly reserved identifiers and cannot be used as names for the program variables or other
user-defined program elements.
Ex: int, class, void etc.

— They refer to the names of variables, functions, arrays, classes etc., created by the programmer.
–Each language has its own rules for naming these identifiers.
— Following are common rules for both C and C++:
o Only alphabetic characters, digits and underscores are permitted.
o The name cannot start with a digit.
o Uppercase and lowercase letters are distinct.
o A declared keyword cannot be used as a variable name.

— Like variables, constants are data storage locations. But variables can vary, constants do not change.
–You must initialize a constant when you create it, and you can not assign new value later, after constant
is initialized.
Defining constant using #define:
–#define is a preprocessor directive that declares symbolic constant.
Example syntax:
#define PI 3.14
— Every time the preprocessor sees the word PI, it puts 3.14 in the text.
using namespace std;
#define PI 3.14
int main()
int r,area;
cout<”enter radius=”” :”;=””>”enter>
cout<”area of=”” circle=””>”area>;>
return 0;
Enter Radius :5
Area of Circle = 78.5
Defining constant using const keyword:
— ‘const’ keyword is used to declare constant variable of any type.
— We cannot change its value during execution of program.
— Syntax: const DataType Variable_Name=value;
Ex: const int a=2;
— Now ‘a’ is a integer type constant.

Explain various Data types used in C++.
– C++ provides following data types.
– We can divide data types into three parts
1. Primary data type
2. Derived data type
3. User defined data type



Derived Data types:
— Following derived data types.
C++ Data Types
Primary data type
– int
– float
– char
– void
Secondary data type
Derived data type
– Pointer
– Function
– Reference
User defined data types
– Class
– Structure
– Union
– enum

1. Arrays
2. Function
3. Pointers
– We cannot use the derived data type without use of primary data type.
– Array: An array is a fixed-size sequenced collection of elements of the same data type.
– Pointer: Pointer is a special variable which contains address of another variable.
– Function: A Group of statements combined in one block for some special purpose.
User Defined Data types:
– We have following type of user defined data type in C++ language.
– The user defined data type is defined by programmer as per his/her requirement.
– Structure: Structure is a collection of logically related data items of different data types grouped together
and known by a single name.
– Union: Union is like a structure, except that each element shares the common memory.
– Class: A class is a template that specifies the fields and methods of things or objects. A class is a prototype
from which objects are created.
-enum: Enum is a user-defined type consisting of a set of named constants called enumerator.
– In other words enum is also used to assign numeric constants to strings
– Syntax of enumeration: enum enum_tag {list of variables};
– Example of enumeration: enum day-of-week {mon=1,tue,wed,thu,fri,sat,sun};