أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.
a) protected,publicb) private,publicc) privated) public
Private
Because it's better to be properly encapsulated and only open up the things that are needed, as opposed to having everything open by default and having to close it.
1. Data members of a class are by default private.
2. A private function of a class can access a public function within the same class.
3. A member function of a class is by default private.
Eg.
public class Program
{
int i = 10;
static void Main(string[] args)
{
}
}
public class Test : Program
{
public void M1()
{
// We are not able to access variable i because i is by default private.
}
}