I was never successful in finding a tutorial that talks about what happens if the encapsulation is not done. Nobody has been able to give an example of how exactly a bad guy can create problems if the encapsulation is missed out.
If I can access private variables by using getter and setter methods then it is contradicting the whole purpose of encapsulation. You cannot access private variables by creating object of that class but you can access those variables by using getter and setter. Will you please elaborate on this?
Hi Naveen, thanks for the explanation. The Getters and Setters are defined outside main but inside the class however can we create the Getters and Setters in another class to access the private instance variables of this class.
Hey Navin, Can you make video on how these oops concept are used in framework. If it's already there please provide the link.. I have searched it in your videos I didn't get it. I am planning to resume my career after maternity. I have 2 years of gap.. It will e great help if you tell me from where to starts which playlist to follow. I have total 4.5 yrs of experience in automation and functional testinfg. But due to gap it's quite difficult to get into market again. I need help.
in real time, we only declare data members as private or we also initialize it ? and is that another reason for data hiding is that if any one wants to reuse the code so they can use it without harming the existing code ?
@Naveen - Just wanted to understand how this approach of declaring class variables as "private" and calling them via getters and setters is different from having a constructor(int ssn, String empName, int empAge) to initialize these class level private variables while creating the object of the class ? - could reduce the lines of code in that case. Also was able to directly get them via objReference.variableName
Vishwanathan Bala I think , in the case of constructor for initialising values, we have to create multiple objects for executing scenarios with multiple values , it’s wasting memory. In this case we can execute multiple values with same object in same run.
In the setter method you can add security measures like checking whether the logged in user has proper entitlements to change the variable if not a message or a popup can be shown telling the user that they don't have sufficient privileges.
Hi Naveen, Thanks for your video..To protect some fields, we are declaring them as private.. But with the help of getter and setter, we can access those as well right? Then what is the actual use of it.. Can you please tell me?
Generally this is considered good practice, because in real world applications , your setter and getter may not be simply be setting the values or getting the values. Example, consider a person class, modelling a person, with a field "age". Without this approach, users, can set age to negative numbers, which is not meaningful, so in a setter, one can restrict the values to be only positive and maybe throw exceptions when the age is negative
I think there's no difference between these two. To my understanding, by using encapsulation, we can completely hide variable or can give access to get or set the variable. That might not be possible without using private. Does this make sense?
Here Naveen explaining everything in one class that’s y you got that confusion. One class with private data variables and public getter and setter. Create object of that class in main class(separate class with main()) , we can only access public methods never private data and private methods( protected n friendly access modes are there it’s availability depends on inheritance and packages etc)..
Naveen AutomationLabs i agree with u naveen all of ur videos are slow and easily catchable only.i thank u alot after searching for a long time i got ur videos.
You are the best in the market
But what is the advantage of encapsulation here? We can change the value of data member by setter method.
I was never successful in finding a tutorial that talks about what happens if the encapsulation is not done. Nobody has been able to give an example of how exactly a bad guy can create problems if the encapsulation is missed out.
Great job. Keep up the good work
This is great !! Thank you Naveen
Awesome video naveen bro
very clear explanation thank you
Hey Naveen, could you please explain the actual difference between Encapsulation and Abstraction.
If I can access private variables by using getter and setter methods then it is contradicting the whole purpose of encapsulation. You cannot access private variables by creating object of that class but you can access those variables by using getter and setter. Will you please elaborate on this?
Thanks a lot sir
Hi Naveen, thanks for the explanation. The Getters and Setters are defined outside main but inside the class however can we create the Getters and Setters in another class to access the private instance variables of this class.
Thank you for your amazing video.
superb
Great job! please more videos.
this was good man thanks for sharing
Was great ,I understood it so well
thanks naveen..
can you please tell me is class variable and instance variable same?
awesome.... keep it up... make more videos on Java oops concepts... And core Java part...more demand from " Pune Maharashtra ".. Thank you so much
Thank you Naveen, great explanation :)
Thanks
Thankyou Greate Teacher!! :)
THANK YOU VERY MUCH .
Thankyou Naveen
Hey Navin,
Can you make video on how these oops concept are used in framework. If it's already there please provide the link.. I have searched it in your videos I didn't get it. I am planning to resume my career after maternity. I have 2 years of gap.. It will e great help if you tell me from where to starts which playlist to follow. I have total 4.5 yrs of experience in automation and functional testinfg. But due to gap it's quite difficult to get into market again. I need help.
if outside person can get the value then where is the security mechanism in encapsulation.
They don't have direct access on private data members, it has to be accessed via public methods. It's upto you want to give access via public layer.
in real time, we only declare data members as private or we also initialize it ? and is that another reason for data hiding is that if any one wants to reuse the code so they can use it without harming the existing code ?
well explained. thank you :)
@Naveen - Just wanted to understand how this approach of declaring class variables as "private" and calling them via getters and setters is different from having a constructor(int ssn, String empName, int empAge) to initialize these class level private variables while creating the object of the class ? - could reduce the lines of code in that case. Also was able to directly get them via objReference.variableName
Vishwanathan Bala I think , in the case of constructor for initialising values, we have to create multiple objects for executing scenarios with multiple values , it’s wasting memory. In this case we can execute multiple values with same object in same run.
Amazing Thank you :)
Hi Naveen, Can you please make one more video on Lambda concept introduced in Java 8.
hi naveen please post how to convert csv to json
thank you from africa i have an exam thank u u saved me alot of reading lol
Awesome :). Keep learning
If outside user of the class is able to change the private variables values through getter and setter methods
Then what is the seecurity point here?
In the setter method you can add security measures like checking whether the logged in user has proper entitlements to change the variable if not a message or a popup can be shown telling the user that they don't have sufficient privileges.
@@shivamdave6252 thank you...needed that explanation as well
Hi Naveen, Thanks for your video..To protect some fields, we are declaring them as private.. But with the help of getter and setter, we can access those as well right? Then what is the actual use of it.. Can you please tell me?
Generally this is considered good practice, because in real world applications , your setter and getter may not be simply be setting the values or getting the values. Example, consider a person class, modelling a person, with a field "age". Without this approach, users, can set age to negative numbers, which is not meaningful, so in a setter, one can restrict the values to be only positive and maybe throw exceptions when the age is negative
emp.setEmpAge(27);
emp.empAge = 30; what is difference between this two?
I think there's no difference between these two. To my understanding, by using encapsulation, we can completely hide variable or can give access to get or set the variable. That might not be possible without using private. Does this make sense?
Here Naveen explaining everything in one class that’s y you got that confusion. One class with private data variables and public getter and setter. Create object of that class in main class(separate class with main()) , we can only access public methods never private data and private methods( protected n friendly access modes are there it’s availability depends on inheritance and packages etc)..
For more visit :
th-cam.com/video/q2RgFH1rPos/w-d-xo.html
dear my brother tell me slowly man.Thankyou
Pardhu Chowdary Mannem it's very slowly explained.
Naveen AutomationLabs i agree with u naveen all of ur videos are slow and easily catchable only.i thank u alot after searching for a long time i got ur videos.