Hi,
Hope you are all doing great. Let's learn together.
Note:
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, James Gosling and his team changed the name from Oak to Java.
Video Links --
Access Modifier. Private, Public, Default, Protected -- • Access Modifier. Private, Public, Default,...
Encapsulation, Data Hiding, Setter-Getter method, JavaBean Class -- • Encapsulation, Data Hiding, Setter-Getter ...
Polymorphism, Method and Constructors Overloading, Method Overriding -- • Polymorphism, Method & Constructors Overlo...
Inheritance, Is-A relationship, the problem with multiple inheritances -- • Inheritance, 'IS-A' relationship, multiple...
Abstraction, Interface -- • What is Abstraction? Interface Implementat...
Abstraction, Abstract Class - • What is Abstraction? Abstract Class Implem...
What is Class, Object, Method, Constructors- • What is Class, Object, Method, Constructo...
Environment Setup and why we need to set path in environment variable -- • Environment Setup. Why do you set a Java p...
First Java Program - "Hello World" -- • First Java Programming "Hello World" Print...
Document Link -
https://docs.google.com/document/d/1G...
Like, Comment, Share, Subscribe.
Thank you again.
STS Link:
https://spring.io/tools
JDK Link:
https://www.oracle.com/java/technolog...
Encapsulation:
Encapsulation is defined as the wrapping up of code and data under a single unit.
How to implement it?
We can create a fully encapsulated class in Java by making all the data members of the class private. Now we can use setter and getter methods to set and get the data. Therefore, it is also known as data hiding.
The Java Bean class is an example of a fully encapsulated class.
Advantages of Encapsulation in Java
1. You can make the class read-only or write-only by providing only a setter or getter method.
2. It provides you the control over the data. Suppose you want to set the value of id which should be greater than 100 only, you can write the logic inside the setter method. You can write the logic not to store the negative numbers in the setter methods.
3. It is a way to achieve data hiding in Java because other classes will not be able to access the data through the private data members.
Java Beans Class:
JavaBeans are classes that encapsulate many objects into a single object (the bean). It is a java class that should follow the following conventions:
1. Must implement Serializable.
2. It should have a public no-arg constructor.
3. All properties in java bean must be private with public getters and setter methods.