C# Programming - Classes and Objects - Discussion

Discussion Forum : Classes and Objects - General Questions (Q.No. 8)
8.
Which of the following statements are correct?
  1. Data members ofa class are by default public.
  2. Data members of a class are by default private.
  3. Member functions of a class are by default public.
  4. A private function of a class can access a public function within the same class.
  5. Member function of a class are by default private.
1, 3, 5
1, 4
2, 4, 5
1, 2, 3
None of these
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
3 comments Page 1 of 1.

Sridhar said:   6 years ago
Why? 1St one is also correct public declared anywhere there is no restriction.

Fation said:   8 years ago
@Venkat.

Only class access modifier it is internal by default. Data members and methods of class (object) it is private and the answer it is correct. Maybe you confused when this class it be base class.

Even when other class inherit from this base class the default access modifier are private. We should change to internal or public or protected access modifier of base class to be inherited from derived class.
(1)

Venkat said:   8 years ago
Not private, internal by default.
(1)

Post your comments here:

Your comments will be displayed after verification.