Difficulty: Easy
Correct Answer: 2, 4, 5
Explanation:
Introduction / Context:
This question checks your understanding of C#.NET's default accessibility for class members (fields and methods) and how access modifiers behave within the same class. Many beginners assume methods default to public, but in C# the default for class members is private unless specified.
Given Data / Assumptions:
Concept / Approach:
In C#, members of a class (fields, methods, properties) default to private. Access modifiers govern visibility outside the class, but inside the same class, all members can call each other regardless of each one’s modifier. Thus a private method can invoke a public method of the same class (and vice versa).
Step-by-Step Solution:
Verification / Alternative check:
Create a class with a field int x; and method void M() { } without modifiers and inspect with IntelliSense or compile-time visibility—both are private.
Why Other Options Are Wrong:
Any option including (1) or (3) is incorrect because they claim a default of public, which is not how C# works.
Common Pitfalls:
Transferring assumptions from languages where defaults differ; forgetting that properties and methods also default to private in classes.
Final Answer:
2, 4, 5
Discussion & Comments