Showing posts with label Java-Basics. Show all posts
Showing posts with label Java-Basics. Show all posts
Tuesday, January 5, 2010
Difference between Protected and Default members - Java
The protected and default access control levels are almost identical with one critical difference. A default memeber can be accessed only if the class accessing the members belong to the same package, whereas a protected member can be accessed [only through inheritence] by a sub class even if the subclass is in a different package.
Monday, December 28, 2009
Java Access Modifiers/Access Level
| Access Level/Modifiers | Public | Protected | Default | Private |
| From the same class | Yes | Yes | Yes | Yes |
| From any class in the same package | Yes | Yes | Yes | No |
| From a subclass in the same package | Yes | Yes | Yes | No |
| From a subclass outside the same package | Yes | Yes, using inheritance | No | No |
| From a any non-subclass outside the package | Yes | No | No | No |
Monday, August 3, 2009
Java - why public static void main
public: The public method can be accessed outside the class or package.
static: To access the static method, there is no need to create object and you need not have an instance of the class to access the method.
void: There is no need by application to return value. JVM launcher do this with it exists.
main(): It is the entry point for the java application.
String args[] : args is an array of string which holds the optional arguments to the class.
static: To access the static method, there is no need to create object and you need not have an instance of the class to access the method.
void: There is no need by application to return value. JVM launcher do this with it exists.
main(): It is the entry point for the java application.
String args[] : args is an array of string which holds the optional arguments to the class.
Subscribe to:
Posts (Atom)