Difficulty: Easy
Correct Answer: 1) Static methods can access only static data. 2) Static methods cannot call instance methods. 4) Instance methods can call static methods and access static data.
Explanation:
Introduction / Context:
Static members are associated with the type, not any particular object instance. This affects what they can access and how they are invoked.
Given Data / Assumptions:
Concept / Approach:
A static method lacks a this
reference; therefore, it cannot touch instance fields or call instance methods unless given an explicit instance. Conversely, instance methods run with this
and can freely call static methods or read static fields. Static data is zero-initialized by the runtime, so explicit initialization is not strictly necessary.
Step-by-Step Solution:
this
in static methods.
Verification / Alternative check:
Compile code that references instance members from a static method; you will get compile-time errors unless you use an instance variable.
Why Other Options Are Wrong:
Common Pitfalls:
Believing static members must be explicitly initialized; the CLR provides default values.
Final Answer:
1, 2, 4
Discussion & Comments