Encapsulation, Data Hiding, Setter-Getter method, JavaBean Class. Bengali - Ep:8 #learnjava #bengali

preview_player
Показать описание
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 --

Document Link -

Like, Comment, Share, Subscribe.

Thank you again.

STS Link:

JDK Link:

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.
Рекомендации по теме
Комментарии
Автор

0:05 what is Encapsulation
0:57 implementation of encapsulation
2:51 implementing encapsulation in code
4:06 Setter Getter Concept
11:50 Diagram of encapsulation
13:39 Advantages of Encapsulation
13:51 Read only access
15:09 Write only access
17:19 Control 9ver data
22:50 java bean class

saptarshi.ghosh
Автор

Encapsulation explained in very simple words... Read-only, Write-only concepts I was unaware of... Thanks for explaining ❤️

saptarshi.ghosh
Автор

Very good explanation of Encapsulation! Very real examples. Simplest way, I understood it fully for the first time after 4 years! 😍😍😍😍💓

ankandas
welcome to shbcf.ru