OA. free
Free
Micron Core Computer Science Core Computer Science Medium

Choose the correct statement(s) from the given options.

Micron technical mcq question, verified with a worked answer. Free to practise - no sign-up.

Choose the correct statement(s) from the given options.

I) Static methods can only access the static members of the class.

II) Static class's object cannot be created, and it only contains static members.

Choose one option.
Show answer & explanation
Answer: D. Neither (I) nor (II)

Statement I is false because static methods can access both static and non-static members (instance members) of the class; they can access non-static members via object references or by creating temporary instances. Statement II is partially misleading because while a static class cannot have instances created (true in languages like C#), the statement conflates two concepts—not all languages enforce 'static class' syntax, and non-static members can technically exist in a static class but cannot be accessed without an instance (which is impossible). Both statements contain inaccuracies or are language-dependent.

Step-by-step Derivation:
Analyze each statement:

Statement I: 'Static methods can only access the static members of the class.'

  • FALSE. Static methods can access static members directly.
  • However, static methods CAN also access non-static (instance) members via object references. Example:
    class MyClass {
      int nonStaticVar = 5;  // instance member
      static int staticVar = 10;  // static member
      static void myStaticMethod() {
        System.out.println(staticVar);  // ✓ Can access static
        MyClass obj = new MyClass();
        System.out.println(obj.nonStaticVar);  // ✓ Can also access non-static via object
      }
    }
    
  • Statement I is INCORRECT.

Statement II: 'Static class's object cannot be created, and it only contains static members.'

  • This is language-specific and imprecise. In C#, static classes cannot be instantiated.
  • However, a static class is NOT required to contain only static members—it CAN declare instance members (though they cannot be used without an object, creating a logical flaw).
  • In Java, there is no 'static class' keyword; only nested classes can be static, and they still can contain instance members.
  • Statement II is MISLEADING/INCORRECT.

Conclusion: Both statements are false. The correct answer is D.