What is Encapsulation in Java - OOP Concept

Поделиться
HTML-код
  • Опубликовано: 5 авг 2024
  • Learn:
    Encapsulation in Java
    Binding Data with Method
    Getters and Setters
    Data Hiding
    Important notes:
    Encapsulation is one of the four fundamental OOP concepts.
    Encapsulation is the technique of making the fields in a class private and providing access to the fields via public methods.
    If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class
    Encapsulation is one of the four fundamental OOP concepts.
    Encapsulation can be defined as a process of wrapping code and data together into a single unit.
    Encapsulation is the technique of making the fields in a class private and providing access to the
    fields via public methods.
    If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class.
    ~~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
    ruclips.net/user/Naveen%20Au...
    Follow me on my Facebook Page:
    / naveenqtpexpert
    Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:
    t.me/joinchat/COJqZQ4enmEt4JA...
    vimeo.com/ondemand/webservice... Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
    ruclips.net/user/Naveen%20Au...
    Follow me on my Facebook Page:
    / naveenqtpexpert
    Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:
    t.me/joinchat/COJqZUPB02r5sB7...
    Paid courses (Recorded) videos:
    Java & Selenium Course: www.naveenautomationlabs.com/p...
    API Course: www.naveenautomationlabs.com/p... ➡️Get Our Courses✔️
    📗 Get My Paid Courses at
    Paid courses (Recorded) videos:
    Java & Selenium Course: www.naveenautomationlabs.com/p...
    API Course: www.naveenautomationlabs.com/p...
    -------------------------------
    ✔️SOCIAL NETWORKS
    Facebook: / naveenqtpexpert
    Twitter: / naveenkhunteta
    Blog: www.naveenautomationlabs.com
    --------------------------------
    Support My Channel✔️Or Buy Me A Coffee
    Paypal: paypal.me/naveenkhunteta
    Google Pay: naveenanimation20@gmail.com
    --------------------------------
    ✔️Thanks for watching!
    देखने के लिए धन्यवाद
    Благодаря за гледането
    感谢您观看
    Merci d'avoir regardé
    Grazie per la visione
    Gracias por ver
    شكرا للمشاهدة
  • НаукаНаука

Комментарии • 49

  • @rajdeepbhattacharjee2301
    @rajdeepbhattacharjee2301 4 года назад +2

    Great job. Keep up the good work

  • @h.rehaief3567
    @h.rehaief3567 5 лет назад +1

    Great job! please more videos.

  • @srinivasbadhamoni2175
    @srinivasbadhamoni2175 6 лет назад +1

    Thank you Naveen, great explanation :)

  • @sindhusudhakaran1731
    @sindhusudhakaran1731 3 года назад +1

    This is great !! Thank you Naveen

  • @alagumuthuakhilachockaling4388
    @alagumuthuakhilachockaling4388 5 лет назад +1

    Was great ,I understood it so well

  • @ILuvBilli
    @ILuvBilli 5 лет назад +3

    But what is the advantage of encapsulation here? We can change the value of data member by setter method.

  • @ramareddybheemanagoud2331
    @ramareddybheemanagoud2331 5 лет назад +1

    Awesome video naveen bro

  • @naziyahasan1577
    @naziyahasan1577 6 лет назад +1

    well explained. thank you :)

  • @rushhour403
    @rushhour403 4 года назад +7

    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.

  • @kubra1975
    @kubra1975 4 года назад +1

    very clear explanation thank you

  • @mariabajwa8632
    @mariabajwa8632 6 лет назад +2

    thanks naveen..

  • @ummerubab6710
    @ummerubab6710 5 лет назад +1

    Thankyou Greate Teacher!! :)

  • @saha6447
    @saha6447 3 года назад

    Thank you for your amazing video.

  • @RaviKumar-sw1wc
    @RaviKumar-sw1wc 5 лет назад +1

    Thankyou Naveen

  • @sitoramarat5945
    @sitoramarat5945 5 лет назад +1

    THANK YOU VERY MUCH .

  • @jiteshsharma4692
    @jiteshsharma4692 5 лет назад +1

    awesome.... keep it up... make more videos on Java oops concepts... And core Java part...more demand from " Pune Maharashtra ".. Thank you so much

  • @agitay272
    @agitay272 3 года назад

    You are the best in the market

  • @MrYashMundey
    @MrYashMundey 4 года назад

    Amazing Thank you :)

  • @bhavanagyarampalli8983
    @bhavanagyarampalli8983 Год назад

    Thanks a lot sir

  • @Fnaf-vh9cs
    @Fnaf-vh9cs 3 года назад

    this was good man thanks for sharing

  • @mohitgupta7145
    @mohitgupta7145 3 года назад +2

    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.

  • @mr.nobody7139
    @mr.nobody7139 4 года назад +4

    Hey Naveen, could you please explain the actual difference between Encapsulation and Abstraction.

  • @saurabh_mahurkar
    @saurabh_mahurkar 3 года назад +2

    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?

  • @puritymushaya8206
    @puritymushaya8206 2 года назад

    superb

  • @jyotibaviskar6282
    @jyotibaviskar6282 3 года назад +1

    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.

  • @ma8969
    @ma8969 2 года назад

    Thanks

  • @shehenazshaik6273
    @shehenazshaik6273 5 лет назад +2

    can you please tell me is class variable and instance variable same?

  • @nalinaksheepanda1596
    @nalinaksheepanda1596 5 лет назад +1

    Hi Naveen, Can you please make one more video on Lambda concept introduced in Java 8.

  • @vishwanathanbala8045
    @vishwanathanbala8045 5 лет назад +1

    @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

    • @nandhanamtalkies2332
      @nandhanamtalkies2332 5 лет назад +1

      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.

  • @kalyanijoshi6884
    @kalyanijoshi6884 6 лет назад +2

    hi naveen please post how to convert csv to json

  • @parthjangid5966
    @parthjangid5966 2 года назад

    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 ?

  • @soundaryasoudi1134
    @soundaryasoudi1134 3 года назад +1

    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?

    • @kobbyfynn8043
      @kobbyfynn8043 2 года назад +2

      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

  • @skyleenkariuki2527
    @skyleenkariuki2527 6 лет назад +2

    thank you from africa i have an exam thank u u saved me alot of reading lol

  • @mohitsingla5436
    @mohitsingla5436 6 лет назад +3

    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?

    • @shivamdave6252
      @shivamdave6252 5 лет назад +7

      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.

    • @hikikomori9387
      @hikikomori9387 5 лет назад +1

      @@shivamdave6252 thank you...needed that explanation as well

  • @SanjayKumar-zx1dv
    @SanjayKumar-zx1dv 2 года назад +1

    if outside person can get the value then where is the security mechanism in encapsulation.

    • @naveenautomationlabs
      @naveenautomationlabs  2 года назад

      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.

  • @mayurpatil5370
    @mayurpatil5370 5 лет назад +2

    emp.setEmpAge(27);
    emp.empAge = 30; what is difference between this two?

    • @yasirmehmood76
      @yasirmehmood76 5 лет назад +1

      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?

    • @nandhanamtalkies2332
      @nandhanamtalkies2332 5 лет назад +2

      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)..

  • @barshabhattacharjee6788
    @barshabhattacharjee6788 3 года назад

    For more visit :
    ruclips.net/video/q2RgFH1rPos/видео.html

  • @pardhasaradhinaidu602
    @pardhasaradhinaidu602 6 лет назад +1

    dear my brother tell me slowly man.Thankyou

    • @naveenautomationlabs
      @naveenautomationlabs  6 лет назад +1

      Pardhu Chowdary Mannem it's very slowly explained.

    • @sreesree7328
      @sreesree7328 5 лет назад +2

      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.