Object-Oriented Programming Concepts

Object-Oriented Programming Concepts

Previous Home Next

 


Java is designed around the principles of object-oriented programming. To truly master Java
 you must understand the theory behind objects.
object ,class,methods and the principles of object oriented programming are the concepts of oops.


Object-oriented programming focuses on data before anything else.
How data is modeled and manipulated through the use of objects is fundamental to any object-oriented program.
Three principles of object oriented programming are  encapsulation,inheritance,polymorphism.

   Objects
An instance is an executable copy of a class. Another name for instance is object.
There can be any number of objects of a given class in memory at any one time.


Classes

A class is a structure that defines the data and the methods to work on that data.
When you write programs in the Java language, all program data is wrapped in a class,
whether it is a class you write or a class you use from the Java platform API libraries

Inheritance

One object-oriented concept that helps objects work together is inheritance.
Inheritance defines relationships among classes in an object-oriented language. In the Java programming language,all classes descend from java.lang.Object and implement its methods. 


Polymorphism
Another way objects work together is to define methods that take other objects as parameters.
 You get even more cooperation and efficiency when the objects are united by a common super class.
All classes in the Java programming language have an inheritance relationship.
   
Encapsulation
One of the key concepts of object-oriented programming is that to modify an object's state,
one of the object's behaviors must be used. Or to put it another way, to modify the data in one of the object's fields, one of its methods must be called. This is called data encapsulation.

Interface
An interface is a group of related methods with empty bodies.
Implementing an interface allows a class to become more formal about the behavior it promises to provide. Interfaces form a contract between the class and the outside world, and this contract is enforced at build time by the compiler

 


 

Previous Home Next