ACCESS MODIFIERS IN JAVA

public is an access modifier, meaning that it is used to set the level of access. You can use access modifiers for classes, attributes, and methods.

For classes, the available modifiers are public or default (left blank), as described below:
public: The class is accessible by any other class.
default: The class is accessible only by classes in the same package.

The following choices are available for attributes and methods:
default: A variable or method declared with no access control modifier is available to any other class in the same package.
public: Accessible from any other class.
protected: Provides the same access as the default access modifier, with the addition that subclasses can access protected methods and variables of the superclass (Subclasses and superclasses are covered in upcoming lessons).
private: Accessible only within the declared class itself.

Comments

Popular posts from this blog

Exp : 1 & 2 : Working with HTML and CSS

DV and LS Routing Algorithm Implementation in ns2

JAVA PROGRAMMING QUESTION BANK FOR PTT-1 (ACADEMIC YEAR 2015-16)