oops concepts in java with example programs
Oops concepts in java
Oops concept is very very important to make java programming
easier and increase your programming skill.Four pillars of oops are Abstraction,Encapsulation,Inheritance,Polymorphism.Another technique to carefully understand in Java is classes and objects.
This article covers very simple notes for Java programming beginners.
What is object and class?
The basics of oops is class and object
Class is a blueprint which defines some properties and behaviors.
An object is an instance of a class which has those properties and
behaviors attached.A class is not allocated memory when it is defined.
An object is allocated memory when it is created
Class and object —> object is defined as real word entities .Object consists of property and some task
Class is a blueprint that object follows, Class consists of many number of objects
Four pillars of oops are
- Abstraction —> Means showing only essential parts and hiding implementation details
- Encapsulation —> Binding variable and method under single entity
- Polymorphism —> Performing the same task in different way or invoking the method different way this can be achieved by Method overloading(compile time polymorphism) -->(Method overriding(runtime polymorphism) --->
- Inheritance —> Acquiring the properties of one class to another class
Types of inheritance in java
Single inheritance(Explanation with notepade and CMD output program)
Multiple inheritance(Explanation with notepade and CMD output program)
Advantages of oops in java
Benefits of oops
Code reusability
Code modularity —> Everything in oops is an objects ; these can be interchanged or removed to meet the users’ need
Easier maintenance
Improve communication between developers and users
Seamless transition from design to implementation
Java oops coding question & answers
Objective type Q&A
Object are combination of code and data that are treated as a single unit
In objects, the behavior of the real-world entities is represented by method
In objects, data members/data elements define the state of an object
Class is a model or blue -print from which an object is created
Binding the data to methods of an object is called encapsulation
Polymorphism provides the mechanism of ‘one name but different implementations’
A class method is used to assign values to private instance variables of a class
Inheritance enable software reusability which saves time in development encourages using previously proven and quality software components
A method call resolved at compile-time is referred to as early binding and a method call resolved at run-time is called late binding
If class A inherits class B, class A is called derived class and class B is called base class
Comments
Post a Comment