English

Assertion (A) : Static method can access static and instance variables. Reason (R) : Static variables can be accessed only by static method. - Computer Applications

Advertisements
Advertisements

Question

Assertion (A): Static method can access static and instance variables.

Reason (R): Static variables can be accessed only by static method.

Options

  • Assertion and Reason both are correct.

  • Assertion is true and Reason is false.

  • Assertion is false and Reason is true.

  • Assertion and Reason both are false.

MCQ

Solution

Assertion and Reason both are false.

Explanation:

The static method can only access itself, whereas an instance variable can be accessed through a class object. Thus, we can conclude that static methods cannot access instance variables without the assistance of an object.

In contrast, static variables can be immediately accessed by both static and instance methods.

shaalaa.com
  Is there an error in this question or solution?
2023-2024 (February) Official
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×