हिंदी

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

प्रश्न

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

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

विकल्प

  • 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

उत्तर

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
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2023-2024 (February) Official
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×