Check out our courses:
Spring and Microservices Weekend Live Batch : [ Ссылка ]
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : [ Ссылка ]
Udemy Courses:
Java:- [ Ссылка ]
Spring:- [ Ссылка ]
Java For Programmers:- [ Ссылка ]
For More Queries WhatsApp or Call on : +919008963671
website : [ Ссылка ]
In this lecture we are discussing:
1)What is encapsulation?
2)how to achieve encapsulation
3)Benefits of encapsulation
4)how to use private data?
#1
What is encapsulation?
= binding data with method to make your program secure is known as encapsulation.
Consider encapsulation as we have capsule and inside capsule everything inside a class is wrapped or encapsulated.
e.g
class A{ private int a;
public void setA(int num){a=num;}
public int getA(){return a;}
}
//here you can see that we can bind data with method inside a curly braces, it seems look like a capsule inside everything is present.
#2
how to achieve encapsulation?
-- through access specifiers private,protected,public,default . We can achieve
encapsulation.
#3
Benefit of encapsulation
i)Helpful in to achieve abstraction
ii)for security point of view it is most beneficial.
iii)you can maintain log file through method when you bind your data with method.
#4
how to use private data?
-- using setters and getters method we can set and get the value of variable.
-- private int num;
public int getNum( )
{
return num;
}
public void setNum(int num)
{
this.num=num;
}
Note:
Always make variable as private and method as public to achieve security in program.
Github repo : [ Ссылка ]
Java:- [ Ссылка ]
Spring:- [ Ссылка ]
More Learning :
Java :- [ Ссылка ]
Python :- [ Ссылка ]
Django :- [ Ссылка ]
JavaScript :- [ Ссылка ]
Node JS :- [ Ссылка ]
Rest Api :-[ Ссылка ]
Servlet :- [ Ссылка ]
Spring Framework :- [ Ссылка ]
Design Patterns in Java :- [ Ссылка ]
Docker :- [ Ссылка ]
Blockchain Tutorial :- [ Ссылка ]
Corda Tutorial:- [ Ссылка ]
Hyperledger Fabric :- [ Ссылка ]
NoSQL Tutorial :- [ Ссылка ]
Mysql Tutorial :- [ Ссылка ]
Data Structures using Java :- [ Ссылка ]
Git Tutorial :- [ Ссылка ]
Donation:
PayPal Id : navinreddy20
[ Ссылка ]
Ещё видео!