107k views
0 votes
What is the purpose of the static keyword in Java?

A. Marks a method as abstract.
B. Indicates that a variable or method belongs to the class rather than an instance of the class.
C. Allows a class to extend another class.
D. Represents the entry point of a Java program.

1 Answer

2 votes

Final answer:

The static keyword in Java indicates that a variable or method belongs to the class rather than an instance of the class.

Step-by-step explanation:

The purpose of the static keyword in Java is to indicate that a variable or method belongs to the class rather than an instance of the class. When a variable or method is declared as static, it can be accessed directly through the class name, without creating an object of the class. This is useful when you want to share data or behavior across all instances of a class.

User Jim Nelson
by
8.3k points