What is the function of a constructor in Java?
جاوا میں کنسٹرکٹر کا کیا کام ہے؟
- It is used to call other methods.
- It initializes an object when it is created.
- It is used to delete objects.
- None of these.
Explanation
A constructor is automatically called when an object is instantiated, setting initial values.
Unlike regular methods, it has the same name as the class and does not have a return type.
Related MCQs
کون سا پروٹوکول غیر محفوظ نیٹ ورک پر محفوظ مواصلاتی چینل قائم کرنے کے لیے استعمال ہوتا ہے؟
- HTTPS (SSL/TLS)
- DHCP
- FTP
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
ایس کیو آر کا مکمل نام کیا ہے؟
- Structured Query Report
- Simple Query Reporter
- Structured Query Reporter
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
جی آئ یو کا مطلب کیا ہے؟
- Graphical Use Interface
- Graphical User Interface
- Graphic User Interface
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
مندرجہ ذیل میں سے کون سا اینٹی وائرس سافٹ ویئر کی قسم نہیں ہے؟
- Chrome
- Norton
- McAfee
- Avast
اس سوال کو وضاحت کے ساتھ پڑھیں
مندرجہ ذیل میں سے کون سا سٹوریج ڈیوائسز زیادہ سے زیادہ ڈیٹا کو محفوظ کر سکتا ہے؟
- Floppy Disk
- Hard Disk
- Compact Disk
- None of the above