Java Access Modifiers
Private Access Modifers
Cannot be used in an interface or inherited
Private void Add (int a, int b) { Return a+b; }
Example for Method
Public int A=10;
Example for Variable
Public Access Modifiers
Give complete visibility of a variable or method across all classes.
Protected Access Modifiers
Has similar features to Private Access Modifiers
Protected Access Modifiers
Method/variable can be inherited but not used in an interface
Private Access Modifiers
Method/variable declared private, not accessible outside their class.
Access Modifiers
Programs need instructions as to what access particular parts of a program have Three types: Public, Private, and Protected Used with classes, methods, and variables
[Access_Modifier] [Returntype] [Method_Name] (args0, args1...argsn) { ... }
Syntax for Method
[Access_Modifier] [datatype] [variable] = [value];
Syntax for Variable