In which access should a constructor be defined, so that object of the class…

2024

In which access should a constructor be defined, so that object of the class can be created in any function?

  1. A.

    Public

  2. B.

    Private

  3. C.

    Protected

  4. D.

    More than one of the above

  5. E.

    None of the above

Attempted by 227 students.

Show answer & explanation

Correct answer: A

To create an object of a class in any function, the constructor must be accessible outside the class.

The public access specifier allows this accessibility, enabling instantiation from any function within the program scope.

किसी भी फ़ंक्शन में क्लास का ऑब्जेक्ट बनाने के लिए, कंस्ट्रक्टर को क्लास के बाहर एक्सेस करने योग्य होना चाहिए।

पब्लिक एक्सेस स्पेसिफायर इस एक्सेस को अनुमति देता है, जिससे प्रोग्राम स्कोप में किसी भी फ़ंक्शन से इंस्टेंसिएशन संभव होता है।

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs