Advertisements
Advertisements
प्रश्न
Method which is a part of a class rather than an instance of the class is termed as ______.
विकल्प
Static method
Non static method
Wrapper class
String method
Advertisements
उत्तर
Method which is a part of a class rather than an instance of the class is termed as static method.
Explanation:
A method that is a part of a class rather than an instance (object) of the class is called a static method.
- A static method belongs to the class itself, not to any individual object.
- It can be called directly using the class name without creating an object.
- Static methods can access only static data members directly.
- In Java, the keyword
staticis used to declare a static method.
संबंधित प्रश्न
What are the two ways of invoking functions?
Differentiate between formal parameter and actual parameter.
How are private members of a class different from public members?
Write a menu-driven program to display the pattern as per the user’s choice.

For an incorrect option, an appropriate error message should be displayed.
Invoking a method by passing the objects of a class is termed as ______.
Assertion (A): Static method can access static and instance variables.
Reason (R): Static variables can be accessed only by static method.
