#40 Encapsulation in Java

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.พ. 2025

ความคิดเห็น • 104

  • @prakrutijani4205
    @prakrutijani4205 ปีที่แล้ว +30

    I m experienced java developer .. i started watching this playlist to refresh but.. i ended up actually learning making me realize.. i dont know stuff still.However, I loved your teaching way.

    • @djrkm9281
      @djrkm9281 หลายเดือนก่อน +1

      I guess experienced != knowledgable

  • @wolverine3419
    @wolverine3419 ปีที่แล้ว +11

    the way you explain this is magical. I went through videos to find out what encapsulation is and from you i found it. Highly Appreciated Man!

    • @MFM88832
      @MFM88832 10 หลายเดือนก่อน

      You've used the perfect word, it is just "magical". Telusko has a special talent for teaching!

  • @sakthipriya8653
    @sakthipriya8653 ปีที่แล้ว +18

    Its 2 complete hrs, I'm still watching your playlist. Hats off Mr. Navin 👏

  • @subajaelango1535
    @subajaelango1535 ปีที่แล้ว +20

    Actually sir you're my favorite trainer 🔥

  • @SoulOfBharat
    @SoulOfBharat 8 หลายเดือนก่อน +1

    there is no hesitation that you are the best trainer. you really understand how one should be taught it means you understand the problem a student face while studying and grasping the concept. love from the capital of india and from Bihar.

  • @dr.renukapatel9403
    @dr.renukapatel9403 2 ปีที่แล้ว +14

    the way you explain any topic is awesome, specially examples....

  • @AyeshaKhan-om9mu
    @AyeshaKhan-om9mu ปีที่แล้ว +22

    Sir your teaching skills are very good 💯 it's very helpful Java playlist for beginners thankyou so much and Allah bless you ✨👍

  • @Sandeep-t1y3g
    @Sandeep-t1y3g ปีที่แล้ว +4

    Sir, you're tin god and one of my favourite and i like you, god will bless you helping a lot for who needs technical stack to grow their skill-set, hope you provide more content like this, finally your flow of explanation was outstanding, and i like you a lot and a lot more...🔥

  • @Mrindia-k8n
    @Mrindia-k8n 9 หลายเดือนก่อน +10

    00:04 Encapsulation is a part of object oriented programming.
    01:33 Data is stored in the brain in the format of variables
    02:57 Data access control in object-oriented programming
    04:22 Private variables can only be accessed within the same class.
    05:56 Data access is restricted using methods.
    07:16 Private variables can only be accessed within the class that they are defined in.
    08:51 Setting values for variables and accessing them using methods.
    10:22 Encapsulation is a way to bind data and methods together

  • @vishnu_kumar143
    @vishnu_kumar143 27 วันที่ผ่านมา

    I had a lot confusion about encapsulation before watching this video..now I feel I can understand this concept effortlessly because of your demonstration ❤🎉thank you so much sir

  • @kishoresrinivas2104
    @kishoresrinivas2104 วันที่ผ่านมา

    Thank you very much for explaining the encapsulation clearly ❤im big fan u Naveen garu you teaching skills are awesome

  • @jananisrivaideesh1316
    @jananisrivaideesh1316 ปีที่แล้ว +5

    You are superb sir💯💯💯the way of teaching is in easily understandable manner

  • @nidhinrv317
    @nidhinrv317 5 หลายเดือนก่อน

    Without any doubt, I can say that your training videos is really helpful for anyone to understand the concepts. Thanks for sharing .

  • @ajayghode3602
    @ajayghode3602 หลายเดือนก่อน +2

    Encapsulation=Binding our data with the methods. Only way to access data is with the methods.

  • @LearnEnglishMM
    @LearnEnglishMM ปีที่แล้ว +23

    You are using examples from personal life; it’s good to let others learn things well. Try to give a minimum of two examples in each video per topic. Thanks.

  • @shortnews1819
    @shortnews1819 2 ปีที่แล้ว +5

    You are Superb, the way you taught is excellent.

  • @Prasanth-x3n
    @Prasanth-x3n 3 หลายเดือนก่อน +1

    you are my favorite traiiner sir😮‍💨😀😀

  • @yashaswinihm4288
    @yashaswinihm4288 ปีที่แล้ว +1

    Just explained like a wow.Omg wow 🔥

  • @KunjJadav-t7j
    @KunjJadav-t7j ปีที่แล้ว +2

    That is fantastic, sir, you are a legend.

  • @dreamboyaarish1321
    @dreamboyaarish1321 หลายเดือนก่อน

    🎉now I know encapsulation,all thanks to you Sir❤

  • @aniketankush218
    @aniketankush218 8 หลายเดือนก่อน

    Sir your way of explaining is just brilliant!👏

  • @RGMUTEX
    @RGMUTEX ปีที่แล้ว

    Your teaching style is marvelous❤. Love from Nepal!

  • @samnasaif4794
    @samnasaif4794 6 หลายเดือนก่อน

    this is absolutely understandable java concepts simply ,thanku naveen sir

  • @debarghyamajumder673
    @debarghyamajumder673 8 หลายเดือนก่อน +1

    Your Teaching is Great Sir! 💛

  • @subbu9739
    @subbu9739 7 หลายเดือนก่อน

    your explination is awesome sir, easy to understand and grasp the concept.thank You🙏

  • @SSbs-p4f
    @SSbs-p4f ปีที่แล้ว

    Sir your explanation is amezing tqs alot you are equal to God for me

  • @muhammedashkar692
    @muhammedashkar692 ปีที่แล้ว +2

    breaks my head and takes his name and says "oh there is his name"🤣🤣

  • @shaikbasha3882
    @shaikbasha3882 ปีที่แล้ว +4

    you stored lot of information in your brain and by seeing itself everyoone can understand :) just kidding , lovely explanation

  • @ashkuna626
    @ashkuna626 4 หลายเดือนก่อน

    This videos are really awesome ❤.
    Thank you so much for your efforts.

  • @SB-pk2ss
    @SB-pk2ss ปีที่แล้ว +2

    you don't need to use a static block if you just want to initialze a field
    private static String name = "Phone";
    would be enough.
    but if you need some complex manipulations, requires several lines of code, than yes, there static blocks come in

  • @sreejakanukuntla6101
    @sreejakanukuntla6101 4 หลายเดือนก่อน

    Thank you for clear explanation sir🙏

  • @ch.Rambabu-goud
    @ch.Rambabu-goud ปีที่แล้ว

    I am extremely happy to see your vedioed

  • @saurabhhedau3300
    @saurabhhedau3300 ปีที่แล้ว

    best ever example you told here sir

  • @DistantGlowingStar
    @DistantGlowingStar ปีที่แล้ว

    Nice explanation of getters and setters

  • @khankashif7586
    @khankashif7586 ปีที่แล้ว

    Explanation way is so easy

  • @vinodonweb
    @vinodonweb ปีที่แล้ว

    amazing teacshing method 👍👍

  • @rahulpawar5927
    @rahulpawar5927 ปีที่แล้ว

    very good explaination sir.

  • @VivekSingh-zh3co
    @VivekSingh-zh3co 5 หลายเดือนก่อน

    Best java Tutorial for beginner or professional

  • @suieyP7
    @suieyP7 ปีที่แล้ว

    Superb sir. Thank you very much.

  • @aishwaryasinnur2256
    @aishwaryasinnur2256 ปีที่แล้ว

    really easy to understand sir 😍😍thanku

  • @vallikumar1281
    @vallikumar1281 2 ปีที่แล้ว +1

    expected one.. Thank you sir..

  • @kaku-bm1ti
    @kaku-bm1ti 10 หลายเดือนก่อน

    thank you sir 👑

  • @ajayghode3602
    @ajayghode3602 หลายเดือนก่อน

    Thank You

  • @reshmashetty1471
    @reshmashetty1471 ปีที่แล้ว

    "break my head and say... Hey! I got the data" 🤣🤣🤣🤣

  • @balajikavitha8835
    @balajikavitha8835 2 ปีที่แล้ว +1

    Nice explanation

  • @it.b.61.prashantsingh87
    @it.b.61.prashantsingh87 11 หลายเดือนก่อน

    Explanantion was top notch! But my question is we use private access modifier so that other classes can't use it, and then we create get and set method through which we can change and access the value, if we are including get and set method for private variable, why we simply can't keep the vaiable public if in the end we need to access and change the data.

    • @justlik3pro
      @justlik3pro 2 หลายเดือนก่อน +1

      Hi! The main reason for using getter and setter methods lies in control and protection over how variables are accessed and modified. If you make a variable public-for example, your age-anyone can directly change it to any value, including invalid ones like 0 or even a negative number. Such values could lead to errors and potentially break your program.
      By using a private variable with a setter method, you can control how the variable is updated. This allows you to add validation, or "sanity checks," in the setter method to ensure that only valid data is assigned to the variable. For instance, you could enforce that age must be positive. This approach maintains data integrity and safeguards against unexpected or invalid changes.
      In short, private variables combined with public setters give you restricted and safe access to variables, ensuring they follow any rules or constraints you set.
      Hope this clears things up!

    • @Ms.Minion
      @Ms.Minion 2 หลายเดือนก่อน

      Great explanation thankyou

  • @vigneshrp1294
    @vigneshrp1294 ปีที่แล้ว +1

    I have a doubt from a long time and couldnt find the answer.......We use access modifiers to control the accessiblity within the program to ensure encapsulation.....so if we have a private variable and if still we can access it through a public getter method then what is the use of having a private variable.....it can be public instead right?

    • @justlik3pro
      @justlik3pro 2 หลายเดือนก่อน +1

      Hi! The main reason for using getter and setter methods lies in control and protection over how variables are accessed and modified. If you make a variable public-for example, your age-anyone can directly change it to any value, including invalid ones like 0 or even a negative number. Such values could lead to errors and potentially break your program.
      By using a private variable with a setter method, you can control how the variable is updated. This allows you to add validation, or "sanity checks," in the setter method to ensure that only valid data is assigned to the variable. For instance, you could enforce that age must be positive. This approach maintains data integrity and safeguards against unexpected or invalid changes.
      In short, private variables combined with public setters give you restricted and safe access to variables, ensuring they follow any rules or constraints you set.
      Hope this clears things up!

    • @vigneshrp1294
      @vigneshrp1294 2 หลายเดือนก่อน

      @ thank you so much

  • @aishasalim9495
    @aishasalim9495 3 วันที่ผ่านมา

    Thank youu

  • @jatinsharma3792
    @jatinsharma3792 ปีที่แล้ว

    Yes, but is it important to make the class in such a way that we should asign the private vable value directly withou using the setter method.? Why we need to create the strcuture to set the data only and to fetch the data ? I mean what is the actual real life purpose of doin this activity which you are saying Encapsulation ?

  • @lepakshirh7419
    @lepakshirh7419 8 หลายเดือนก่อน

    Tqsm sir for sharing knowledge thoroughly🤝🫂

  • @luckygold777
    @luckygold777 ปีที่แล้ว +1

    Sir, can u please tell me what is the point if we can access the data and change the data even if it's private? what is the advantage of the variable not being accessed directly.....Please respond as soon as possible sir.

    • @a.m.e.e.e.r
      @a.m.e.e.e.r ปีที่แล้ว

      As you heard he said only via methods, so if you don't make "setName" method for example, no one can change the data, while they can GET the data via "getName" it depends on the methods you create. and yeah everyone can touch it if they have your pc, but it's different when it's on the app/game/web you make. Hope it helped. 😊

  • @navasshariff.s9426
    @navasshariff.s9426 ปีที่แล้ว

    Allah bless uuu🎉

  • @Mrindia-k8n
    @Mrindia-k8n 9 หลายเดือนก่อน +1

    HE is talking about the movie wall -e where he used the words pixel
    pls give a me a like

  • @aanchalthakur9088
    @aanchalthakur9088 6 หลายเดือนก่อน

    sir i got ur point but in set method why we used void returntype as uh had told in method concept that we use void as returntype when we dont want to return anything ....plz clear this doubt of mine

    • @VikasReddy-r6y
      @VikasReddy-r6y 5 หลายเดือนก่อน +1

      it is because in set method we only want to modify the field(variable) . Generally we don't expect the function to give us any value. The methods job is to take the input argument and assign it to object's variable

  • @syedfaizan5841
    @syedfaizan5841 ปีที่แล้ว

    Thanks ❤

  • @adityapatil7396
    @adityapatil7396 ปีที่แล้ว

    Can we achieve encapsulation by declaring variables protected instead of private ?

  • @broyea6943
    @broyea6943 ปีที่แล้ว

    I just learned about encapsulation right now😂, does this mean I should stop using constructors and use setters instead?

  • @shivanatchiyarmariammal
    @shivanatchiyarmariammal 6 หลายเดือนก่อน

    instaead of the word behaviour we can use methods right ..? please correct me If I am wrong ...!

    • @vinushas9719
      @vinushas9719 หลายเดือนก่อน

      yup you can behaviour means you are doing an action ~ function~ method :)

  • @HamidahHamie
    @HamidahHamie 2 หลายเดือนก่อน

    I'm trying to catch up something though not used to vs code

  • @vinaysaiakula9475
    @vinaysaiakula9475 ปีที่แล้ว

    Sir what if we keep method as private 🤔

  • @surajdevv
    @surajdevv 2 หลายเดือนก่อน +1

    29/11/2024 -> Streak 1 completed

  • @manikandans1996
    @manikandans1996 ปีที่แล้ว +1

    Sir pls provide notes for this playlist

  • @chemistryworl
    @chemistryworl ปีที่แล้ว

    U r lit sir 🔥

  • @Mehedihasan-rahat
    @Mehedihasan-rahat หลายเดือนก่อน

    Mr.Navin PHP OOP should be in your consideration in TH-cam plz❤

  • @iam_robinroy
    @iam_robinroy ปีที่แล้ว

    ❤tnku sir

  • @yashjangid4222
    @yashjangid4222 3 หลายเดือนก่อน +1

    ya sir we are ailiens 🤣🤣

  • @rdxdevil5083
    @rdxdevil5083 ปีที่แล้ว

    very good sir i got it
    but encapsulation means only public method can access it
    encapsulation means data hiding
    but we are going to public the data
    can someone clear mt doubt....

    • @neerajgarg9096
      @neerajgarg9096 ปีที่แล้ว +1

      we are not going to public data member instead we are going to public the member functions which help to get and set the value of our private data member
      see the below code
      class Encapsulation{
      private int x;
      // now this data member is hidden from outside world as it is private but to set its value and get its value we need to define functions which are public and can be used
      public void set(int a){
      x=a;
      }
      public int get(){
      return x;
      }
      }

  • @prabhneo
    @prabhneo 11 หลายเดือนก่อน +1

    @Telusko
    I have a question sir,
    We can even call the getAge() method by simply passing the value and calling it under Demo class, even age is private in class Human. I tried it and worked well, which states that we don't need setAge() method to set the value, can simply pass through the getAge() and fetch the value.
    Please explain sir, how I am wrong and why do we need get, set methods here? I am pretty sure there must be point behind there :)
    For eg:
    public int getAge(int a)
    {
    age = a;
    return a;
    }
    And while calling it under class demo, we can define:
    Human obj = new Human();
    int final = obj.getAge(56);
    System.out.println(final);

    • @Tolly633
      @Tolly633 11 หลายเดือนก่อน

      If u try to just age()method passing the value under demo class from calling function age method to called function age() without get method. If u can declare variables as private u can't access variables without set or get methods. But u did declare variables as private at the same time u used get /set method. That's the reason u got an output(u haven't no error)

    • @Sarath17
      @Sarath17 5 หลายเดือนก่อน

      anyhow you are setting the value inside that method, that's why there is no error. they are not the default methods right?

  • @sirrisathwik8332
    @sirrisathwik8332 ปีที่แล้ว +3

    telugaa bhaiyaa

  • @ganeshkumarv3895
    @ganeshkumarv3895 2 ปีที่แล้ว +1

    why there isn't this.age = age or return this.age ?

    • @aeroabrar_31
      @aeroabrar_31 ปีที่แล้ว

      Yes you can, but the variable name which is coming as a parameter should be 'age' .

    • @ArpithaHK
      @ArpithaHK ปีที่แล้ว +2

      The parameter which is passing to setter method is same as the instance variable, then "this" must be used.
      for ex:
      public void setAge(String age); {
      this.age = age;
      }

    • @sachinkhatri1077
      @sachinkhatri1077 ปีที่แล้ว

      U can use that if u set your methods parameters name exactly like instance variables. By the way thats a good practice to use proper name in methods and use this keyword to refer.

  • @puruagni1927
    @puruagni1927 9 หลายเดือนก่อน

    Why are you not updating VS Code? Please update VS Code.

  • @NirajKumar-ip1gq
    @NirajKumar-ip1gq ปีที่แล้ว

    obj.setAge(a: 30); I didn't understood this

  • @kitsune-hc5zk
    @kitsune-hc5zk 5 หลายเดือนก่อน

    so its basically POJO and BEANs

  • @adithidesai8690
    @adithidesai8690 ปีที่แล้ว

    6:28 Jeffrey Dahmer's way of accessing the data

  • @kvelez
    @kvelez ปีที่แล้ว

    public class Main{
    public static void main(String[] args) {
    Human me = new Human(30, "Mario");
    System.out.println(me.GetName() + " " + me.GetAge());
    }
    }
    class Human{
    private int age;//private attribute
    private String name;
    public Human(int age, String name){//constructor
    this.age = age;//setting
    this.name = name;
    }
    public void SetAge(int age){//set value
    this.age = age;
    }
    public int GetAge(){//output
    return age;
    }
    public void SetName(String name){//setter
    this.name = name;
    }
    public String GetName(){//getter
    return name;
    }
    }

  • @prudvidiyya9226
    @prudvidiyya9226 ปีที่แล้ว

  • @0shaad
    @0shaad ปีที่แล้ว

    adam scandler's pixel

  • @MallidisrisaiVenkatareddy
    @MallidisrisaiVenkatareddy 4 หลายเดือนก่อน

    Are you from telugu

  • @princet0429
    @princet0429 ปีที่แล้ว

    mm

  • @Unknown373d
    @Unknown373d 8 หลายเดือนก่อน

    fire uuuuu

  • @sultankodirov
    @sultankodirov ปีที่แล้ว

    you can user my name as a trainer hahahaaahahhaahahahah

    • @sultankodirov
      @sultankodirov ปีที่แล้ว

      I use by the way )))))hahahaha

  • @authenticworld7271
    @authenticworld7271 2 ปีที่แล้ว +1

    And your age is 41

    • @thebacheafghan
      @thebacheafghan ปีที่แล้ว +3

      you cannot define someone's age. you are ageist. you are cancelled.

  • @dummyaxle2099
    @dummyaxle2099 ปีที่แล้ว

    You use too many words, cut it by 1/3