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

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