ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

The data members of a class by default are ?

a) protected,publicb) private,publicc) privated) public

user-image
تم إضافة السؤال من قبل Mohannad Bakbouk , Full Stack Web Developer , Almohtaseb
تاريخ النشر: 2016/10/21
Shahid Salam Khan
من قبل Shahid Salam Khan , Software Engineer , Xavient Information Systems

By default the data members of a class are Private

anas alhashki
من قبل anas alhashki , Senior Full Stack Engineer , Industrial Motor Power Corporation

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.

 

Amit Sharma
من قبل Amit Sharma , Systems Analyst , TCS

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.

        }

 

    }

المزيد من الأسئلة المماثلة