Quick Guide to OOPS Concepts W3Schools. Java OOPS Concepts Tutorial.
OOPS Concepts in JavaIn this tutorial, We'll explore about oops concepts in java w3schools with examples. If you are new to Java programming, You should know the concepts of Object Oriented Programming(OOP) before you start writing coding. This tutorial let you know Classes, Object, Packages, Encapsulation, Inheritance, Polymorphism, Abstraction.
In Java, Please consider behavior means a method how it works or behave called as "behavior".
W3schools Object Oriented Programming:
One prime characteristic that is constant in the world of software is the change and advancement in software. That change is one of the most critical aspects of software development. Development of new tools and techniques is common for everyday technology users. For software engineers, the most important thing is the maintainability, portability, re-usability, integrity, security, and user-friendliness. So to build today's sophisticated software it is just not enough to put together a sequence of programming statements or procedures. Programmers need to use sound construction techniques and program structures that are easy to figure out implement and modify in a wide variety of situations. It is possible and efficient to use with Object-oriented Programming techniques.
Top Objectives of OOP(Object Oriented Programming):The emphasis is on the data rather than the procedures.
Methods that operate on data are tied together in a data structure.
Programs are divided into small instance called Objects.
Data remains hidden and cannot be accessed by external functions.
Objects may communicate with each other through methods.
The programs follow the bottom-up approach.
New data and methods can be easily added whenever necessary.
Basic Terms and Concepts that used in OOPS:
- Classes and Objects
- Data Abstraction
- Data encapsulation
- Dynamic Binding
Java has following OOPS features: Encapsulation. Inheritance. Polymorphism. Abstraction. Classes. Objects. Instance. Method.
What is Class :
Class defines blueprint or set of properties of Objects. Class name conventions are first letter should be capital letter and meaningful. If we want to write a class to read content from buffer so we can say name as "bufferedreader" but this should follow naming convention. Each letter in word should be upper case. Eg. "BufferedReader", "FileReader", ..
What is Object :
Object is which holds state and behaviour. Once class can have different states and behaviours. For example, Car class can have first object with name "Ford" and second object with "Audi" with different engines.
What is Package :
Package is which describes about class location where it is located in project.
What is Encapsulation:
Encapsulation is which describes about bringing together members and its behavior. Java supports Encapsulation principle but it default does not come with Encapsulation. When we write code, we have to implement it using its principles. Encapsulation provides maintainability, flexibility, and extensibility of the code.
What is Inheritance :
Java has powerful mechanism to get the access of state and behaviour of another class and can make well structured and design project.
What is Polymorphism:Actual dictionary meaning of Polymorphism is one organism can have many forms. The same logic also has been applied to Java. Behaviour can be changed with same method names.
What is Abstraction:Abstract means ""existing in thought or as an idea but not having a physical or concrete existence". In Java, hiding the behaviour implementation.
Abstract classes example
Main Advantages of OOPS:
- Code recycle and reuse.
- Wrapping up of data into a single unit.
- Easy to partition the work in a project based on objects.
- Message passing technique between objects for communication makes interface description with external systems much more straightforward.
- Software Complexity can be easily handled and managed.
- Possible to map objects in a problem domain within a program.
- Data hiding is possible.
- Use of inheritance can eliminate redundant codes in a program