Asked by Raheal Pasha on Jun 06, 2024

verifed

Verified

Which modifier is used to specify that a method cannot be used outside a class?

A) public
B) abstract
C) static
D) private

Modifier

A keyword in programming languages that you use to specify the properties of an attribute, method, or class, such as public, private, or static.

Specify

To specify means to identify something clearly and explicitly.

Outside A Class

Refers to code or functions that are defined or executed outside of a class definition in object-oriented programming.

  • Gain insight into declaring methods and executing method calls within Java.
verifed

Verified Answer

MD
Molly DulapaJun 10, 2024
Final Answer :
D
Explanation :
The private modifier specifies that a method can only be accessed within the class it is declared in, making it impossible to use outside the class. The public modifier allows the method to be accessed from anywhere in the program, while the abstract modifier is used for creating abstract classes and methods, and the static modifier is used for creating methods and variables that belong to the class itself rather than an instance of the class.