Lesson 27 of 34
Encapsulation: private, getters, settersEncapsulation: private, Getters and Setters
9 min 35 XP
Fields-ஐ private ஆக்கினால் class-க்கு வெளியிலிருந்து நேரடியாக மாற்ற முடியாது. getter மூலம் படிக்கலாம், setter மூலம் சரிபார்த்து மாற்றலாம். இதுவே encapsulation, OOP-ன் நான்கு தூண்களில் ஒன்று.
Make fields private so code outside the class can't change them directly. A getter reads the value; a setter changes it after checking it. This is encapsulation, one of the four pillars of OOP.
Example: edit me and press Run
Press Run to see the result here.OOP-ன் நான்கு தூண்கள்: Encapsulation, Inheritance, Polymorphism, Abstraction. Interview-ல் ஒவ்வொன்றுக்கும் ஒரு உதாரணம் சொல்லத் தயாராக இருங்கள்.
The four pillars of OOP: Encapsulation, Inheritance, Polymorphism and Abstraction. Be ready to give an example of each in interviews.