Java is a programming language and a platform. Java is a high level, robust, object-oriented and secure programming language.
Java was developed by Sun Microsystems (which is now the subsidiary of Oracle) in the year 1995. James Gosling is known as the father of Java. Before Java, its name was Oak. Since Oak was already a registered company, so James Gosling and his team changed the name from Oak to Java.
Creating Your First Java Program
Create a new file in your text editor or IDE named HelloWorld.java. Then paste this code block into the file and
save:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Concepts in OOPS
➔ Object
➔ Class
➔ Inheritance
➔ Encapsulation
➔ Abstraction
➔ Polymorphism
1. Object
➔ Any real world entity is an object. It has
Behavior and Attribute.
➔ Behavior tells what object does or
performs.
➔ Attribute is use to describe the object.
Chair🪑
It can be considered as an object, with
behaviors like wheel movement, adjust
height, recline, etc. and attributes like
color, brand, price, etc.
2. Class
➔ The collection of all related objects is
called Class.
➔ Consider class as a general category
which contains all the related objects
inside it.
Chair🪑
Objects like Wheel chair, Office chair,
Recliner chair belong to Chair class.
3. Inheritance
➔ In real world, a Child inherits qualities from his/her
Parent.
➔ Similarly, a Child class can also inherit qualities
from it's Parent class.
Phone
Parent class Phone can have two child classes -
Both these child classes can inherit the calling
behavior.
4. Encapsulation
➔ It means wrapping the data into a single
unit & securing it.
➔ It secures data from the outside world.
Bank Locker🔐
A Banker Locker, wraps your valuables into a
single unit(locker) and protects it via
passcode.
Drug Capsule💊
Wraps different medicines into a single unit
and protect them from outside
environment.
5. Abstraction
➔ Hiding complexity from the user and
showing only the relative stuff.
➔ This enables user to only focus on
relevant stuff.
Car
- In car, all the complexity like engine,
machinery, etc is hidden from you.
- Only relevant part is shown like the
brakes, accelerator, and gearbox.
6. Polymorphism
➔ The word polymorphism means many forms.
➔ It talks about using the same name and
providing different behaviour.
Chess
All chess pieces like king, rook, bishop, queen,
knight, etc. move differently. Bishop moves
diagonally, Rooks move horizontal and vertical,
etc.
The common behavior name "move" is the
same for all pieces but it's still differently done
by them which is nothing but polymorphism.
0 Comments
Thanks for Supporting me