KnowledgeBoat Logo

Computer Applications

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

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

  1. Assertion and Reason both are correct.
  2. Assertion is true and Reason is false.
  3. Assertion is false and Reason is true.
  4. Assertion and Reason both are false.

User Defined Methods

ICSE 2024

7 Likes

Answer

Assertion and Reason both are false.

Reason — A static method can only access static variables and static methods directly because it belongs to the class, not any specific object. Hence, Assertion is false.
Both instance and static methods can access static variables. Hence, Reason is false.

Answered By

4 Likes


Related Questions