this keyword: ============= ==> when the parameter names of the constructor and variables/data members of the class with different names we don't required to use the "this" keyword. ==> when the parameter names of the constructor and variables of the class with the same names, then we should use "this" keyword for distinguishing the class data member and parameters. ex: parameter name and class data members with different names ============================================================== class ClassA{ int a; int b; ClassA(int x, int y) { a = x; b = y; } } public class MainClass{ public static void main(String[] args) { ClassA ca = new ClassA(10,20); } } ex:2) parameter names and class data members with same names ============================================================= ===== class ClassB{ int x; int y; ClassB(int x, int y) { this.x = x; this.y = y; } } public class MainClass{ public static void main(String[] args) { ClassB cb = new ClassB(100,200); } } ex:3) If we have two different objects for the same class ========================================================== class ClassC{ int a; int b; ClassC(int a, int b) { this.a = a; this.b = b; } } public class MainClass{ public static void main(String[] args) { // first object ClassC cc1 = new ClassC(200,400); // second object ClassC cc2 = new ClassC(300,600); } } ==> this keyword can represent only one class-object at a time. ================================================================ Access Modifiers: ================= ex: engineering reverse engineering ex: private int x = 10; ==> Modifier: a word can change the operation by adding with extra word ==> Modifiers are classified into: 2-types: 1) Access Modifiers 2) Non-Access Modifiers => static, volatile, synchronized etc. 1) Access Modifiers: ==================== ==> 4-types: 1) default 2) private 3) public 4) protected ==> the access modifiers can use represent "scope of the data" or "visibility of the data". Local variables ==> block scope Global Variables default: ======== ==> when the variables/classes/methods/constructor without any keyword of access modifier, we can consider those as "default" members. ==> to define the default members, no "default" keyword can use. ==> The default members can allowed to access within the same package among different classes but not in outside the package. private: ======== ==> private is the keyword we can use to define the private members (variables) ==> private data can able to access within the same class only not in outside of the class. protected: ========== ==> protected is the keyword use to define the protected members (variables/methods/constructors) ==> the scope: within the package ==> if classB is the child class to ClassA. Here: ClassB ==> Packagae2 ClassA ==> Package1 ClassB extends ClassA{ } the protected variable can be visible in child class when child and parent classes are from two different packages. public: ======= ==> public data members can able to access in any where of the program ==> within the same package and in outside the package. public > protected > default > private