OOPS Principles/Concepts
In real industry we have two model of programming language they are
Procedure Oriented Programming languages
Object Oriented Programming languages
In the software development, procedure oriented programming language are always used for developing applications related to system software and application software (Standalone applications development)
Procedure Oriented Programming languages
Object Oriented Programming languages
In the software development, procedure oriented programming language are always used for developing applications related to system software and application software (Standalone applications development)
According to industry standards it is not recommended to develop distributed applications with procedure oriented programming languages. If we develop then we get the following limitations
1. Security problems are more
2. The data is visiting between client and server side applications in the form of plain
text.
3. The data is visiting between client and server side programs in the form of byte by
byte and it gives poor communication.
4. On overall performance of such applications will be degraded (reduced).
5. The data is around the functions causes accessing problems.
To avoid the above problems in development of distributed applications we use object oriented programming language.
Ex: -
C, ALGOL, Pascal, COBOL etc… are comes under Procedure oriented programming language.
1. Security problems are more
2. The data is visiting between client and server side applications in the form of plain
text.
3. The data is visiting between client and server side programs in the form of byte by
byte and it gives poor communication.
4. On overall performance of such applications will be degraded (reduced).
5. The data is around the functions causes accessing problems.
To avoid the above problems in development of distributed applications we use object oriented programming language.
Ex: -
C, ALGOL, Pascal, COBOL etc… are comes under Procedure oriented programming language.
The basic advantages of Object oriented programming are
Security is achieved
The data is visited in the form of cypher text in the form of (encrypt format)
The data will be visited all at once between client and server side applications and it improves effective communication.
Performance of the applications are enhanced (improved)
The data is around the object.
Code reusability is more etc…
Ex: -
Ada, object Pascal, object COBOL, small talk, java, .net, etc…
In order to say many languages are object oriented it has to satisfy all the features/principles of object orientation.
1. Classes
2. Object
3. Data abstraction
4. Data encapsulation
5. Inheritance
6. Polymorphism
7. Dynamic binding
8. Message passing
All the above oops principles are common for all object oriented programming languages but their implementation/syntax is varying/changing from one object oriented programming language to another oriented programming language
Security is achieved
The data is visited in the form of cypher text in the form of (encrypt format)
The data will be visited all at once between client and server side applications and it improves effective communication.
Performance of the applications are enhanced (improved)
The data is around the object.
Code reusability is more etc…
Ex: -
Ada, object Pascal, object COBOL, small talk, java, .net, etc…
In order to say many languages are object oriented it has to satisfy all the features/principles of object orientation.
1. Classes
2. Object
3. Data abstraction
4. Data encapsulation
5. Inheritance
6. Polymorphism
7. Dynamic binding
8. Message passing
All the above oops principles are common for all object oriented programming languages but their implementation/syntax is varying/changing from one object oriented programming language to another oriented programming language
Why c++ is partial oop language?
Even though c++ programing language is available under object oriented, according to industry experts c++ is one of the partial object oriented because of the following reasons
1. Each and every C++ program can be exactly written like C.
2. The C++program may or may not satisfy all the oops principles.
3· C++ programming contains a concept called friend functions which can access
private data which is not recommended in the software development and leads to
security problems.
Even though c++ programing language is available under object oriented, according to industry experts c++ is one of the partial object oriented because of the following reasons
1. Each and every C++ program can be exactly written like C.
2. The C++program may or may not satisfy all the oops principles.
3· C++ programming contains a concept called friend functions which can access
private data which is not recommended in the software development and leads to
security problems.
Note: -
Technically java is one of the pure object oriented programming language because of the following reasons
1. Each and every java program completely satisfies all oops principles
2· Java programming does not containing friend functions etc…
Class: -
Class concept is always used for developing the user/programmer defined data types, user-defined data types and whose variables allow us to store different type of values (or) simple type of values (or) both in a single variable.
In java programming class concept will be developed by using a keyword Class.
Each and every class name acts as a user/programmer defined data types.
Definition: -
The process of binding data members and associated methods in a single unit is known as a Class.
(or)
A class is a collection of data members and associated methods.
In java programming data members of a class are also known as attributes (or) fields (or) properties and methods of a class are also known as Accessories (or) behaviors.
When we defined a class, there is no memory space is created for the data members and methods, memory space will be created for the data members and methods of a class when we create an object with respective to a class.
Hence all classes will have logical existence and all objects are having physical existence.
In object oriented programming we have two types of methods they are
1. Members methods
2. Non – members methods
Technically java is one of the pure object oriented programming language because of the following reasons
1. Each and every java program completely satisfies all oops principles
2· Java programming does not containing friend functions etc…
Class: -
Class concept is always used for developing the user/programmer defined data types, user-defined data types and whose variables allow us to store different type of values (or) simple type of values (or) both in a single variable.
In java programming class concept will be developed by using a keyword Class.
Each and every class name acts as a user/programmer defined data types.
Definition: -
The process of binding data members and associated methods in a single unit is known as a Class.
(or)
A class is a collection of data members and associated methods.
In java programming data members of a class are also known as attributes (or) fields (or) properties and methods of a class are also known as Accessories (or) behaviors.
When we defined a class, there is no memory space is created for the data members and methods, memory space will be created for the data members and methods of a class when we create an object with respective to a class.
Hence all classes will have logical existence and all objects are having physical existence.
In object oriented programming we have two types of methods they are
1. Members methods
2. Non – members methods
A member method is one which is available within the scope of the class and they can access the data members of the class.
A non-member method is one which is not available within the scope of the class and they cannot access the data members of the class.
Java programming allows only the concept of member methods but it never allows non-member methods concept.
In the real world class definition are expressed in class diagrams, class diagram contains three parts and whose structure is below.
A non-member method is one which is not available within the scope of the class and they cannot access the data members of the class.
Java programming allows only the concept of member methods but it never allows non-member methods concept.
In the real world class definition are expressed in class diagrams, class diagram contains three parts and whose structure is below.
The above diagram is common for all object oriented programmers and whose implementation is varying from one object oriented programming language to another object oriented programming language.
Syntax for defining a class: -
Class <class name>
{
Variable declaration;
Methods definitions;
}
Class <class name>
{
Variable declaration;
Methods definitions;
}
1. In the above syntax class is a keyword used for developing user/programmer
defined data type.
2. <class name> represents name of the java valid variable name treated as a class
name. In java programming every class name acts as a user-defined data type.
3. Whenever we defined a class name, no memory space is created for the data
members and methods of a class. Memory space will be created on the data
members and methods of a class when we create an object.
4. Variable declaration represents data members of the class and they will be selected
based on the class name.
5. Method definition represents type of method meant for performing some specific
operations and they will be selected depends on the class name.
6. Each and every method of java must be defined inside the class only that is in java
programming there is no concept of defining the methods outside the class.
7. Each and every definition of class must be incorporated with in {and} and the
definition of class may (or) may not be terminated by semicolon (;).
defined data type.
2. <class name> represents name of the java valid variable name treated as a class
name. In java programming every class name acts as a user-defined data type.
3. Whenever we defined a class name, no memory space is created for the data
members and methods of a class. Memory space will be created on the data
members and methods of a class when we create an object.
4. Variable declaration represents data members of the class and they will be selected
based on the class name.
5. Method definition represents type of method meant for performing some specific
operations and they will be selected depends on the class name.
6. Each and every method of java must be defined inside the class only that is in java
programming there is no concept of defining the methods outside the class.
7. Each and every definition of class must be incorporated with in {and} and the
definition of class may (or) may not be terminated by semicolon (;).
Ex: -
Class Student
{
int id;
string name;
float m1, m2, m3;
int getNoHoursStudy()
{
return (3);
}
float getTotalMarks()
{
return (m1+m2+m3);
}
string getGrade()
{
return( “ Distinction” );
}
} //class
Class Student
{
int id;
string name;
float m1, m2, m3;
int getNoHoursStudy()
{
return (3);
}
float getTotalMarks()
{
return (m1+m2+m3);
}
string getGrade()
{
return( “ Distinction” );
}
} //class
Here each and every java programming must starts with a concept called class that is without class concept there is no java program.
Object: -
Whenever we want to enter the values for the data members of the class, first we have to create the memory space for data members of the class by creating object with respective class.
Each and every data processing must be performed with respective object. To create an object we require class definition to exist.
Hence, in java programming to develop any application there should exists a class definition and later objects will be created with respective to the class.
Definition of object: -
Instance of a class is known as an object (instance is nothing but creating sufficient memory space for the data members and methods of a class).
Every class variable is known as an object.
Grouped item is known as an object (a grouped item is a variable which allows us to place multiple values either of same type (or) different type (or) both the types.
Creating an object: -
Creating an object is nothing but allocating memory space for the data members and methods of a class by following Dynamic memory allocation by using new operator.
Functions of new operator: -
While we are using new operator for creating an object internally it performs the following operations.
a) It allocates sufficient amount of memory space for the data members and methods
of a class.
b) It takes an address/reference of a loaded class and places it in to left hand side
(L.H.S) variable that is object name.
To create an object we have two approaches they are
Object: -
Whenever we want to enter the values for the data members of the class, first we have to create the memory space for data members of the class by creating object with respective class.
Each and every data processing must be performed with respective object. To create an object we require class definition to exist.
Hence, in java programming to develop any application there should exists a class definition and later objects will be created with respective to the class.
Definition of object: -
Instance of a class is known as an object (instance is nothing but creating sufficient memory space for the data members and methods of a class).
Every class variable is known as an object.
Grouped item is known as an object (a grouped item is a variable which allows us to place multiple values either of same type (or) different type (or) both the types.
Creating an object: -
Creating an object is nothing but allocating memory space for the data members and methods of a class by following Dynamic memory allocation by using new operator.
Functions of new operator: -
While we are using new operator for creating an object internally it performs the following operations.
a) It allocates sufficient amount of memory space for the data members and methods
of a class.
b) It takes an address/reference of a loaded class and places it in to left hand side
(L.H.S) variable that is object name.
To create an object we have two approaches they are
Approach 1: -
Sytnax: <cls name> objname = new <clsname()>; Ex: - Student s = new Student(); |
Approach 2: -
Syntax: <cls name> obj name; ------> 1 Obj name = new <cls name()> ; ----> 2 |
Statement 1 represents object Declaration, whenever the object is declared whose default value is null which indicates no memory space is created for the data members of specified class.
Statement 2 represents object referencing, whenever an object is reference whose default value is not null which indicates memory space is created for the data members and methods of the class.
Ex: -
Student s; // object declaration
S = new Student(); // object referencing
Define Class Loader Sub System
A class loader sub system is a program developed by sun micro system and added as a part of JVM and it is used for loading (or) transferring dot class files (.class) from secondary memory to main memory.
What are the difference between classes and objects?
1. The process of binding the data members and associated methods in a single unit is
called Class.
2. when we define a class no memory space is created for the data members and
methods of a class
3. All the classes will have logical existence.
4. When we execute a java program class loads, the corresponding class will be loaded
only ones in the main memory first.
5. Programmatically the definition of a class will exists only once.
Statement 2 represents object referencing, whenever an object is reference whose default value is not null which indicates memory space is created for the data members and methods of the class.
Ex: -
Student s; // object declaration
S = new Student(); // object referencing
Define Class Loader Sub System
A class loader sub system is a program developed by sun micro system and added as a part of JVM and it is used for loading (or) transferring dot class files (.class) from secondary memory to main memory.
What are the difference between classes and objects?
1. The process of binding the data members and associated methods in a single unit is
called Class.
2. when we define a class no memory space is created for the data members and
methods of a class
3. All the classes will have logical existence.
4. When we execute a java program class loads, the corresponding class will be loaded
only ones in the main memory first.
5. Programmatically the definition of a class will exists only once.
1. Instance of a class is known as Object.
2. when we create an object memory space is created for the data members and
methods of a class
3. All the objects will have Physical existence.
4. After loading classes in the main memory objects will be created.
5. With respective one class, we can create multiple objects.
Note: -
All objects of java reside in Heap memory.
All the methods of java reside in stack memory.
All the constant values reside in Associative memory.
All the above three memories are the parts of main memory.
2. when we create an object memory space is created for the data members and
methods of a class
3. All the objects will have Physical existence.
4. After loading classes in the main memory objects will be created.
5. With respective one class, we can create multiple objects.
Note: -
All objects of java reside in Heap memory.
All the methods of java reside in stack memory.
All the constant values reside in Associative memory.
All the above three memories are the parts of main memory.
Visitors