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
- Format
- Modify
- Draw
- Tools
اس سوال کو وضاحت کے ساتھ پڑھیں
- Trim
- Offset
- Extrude
- Fillet
اس سوال کو وضاحت کے ساتھ پڑھیں
بڑی اسکرین پر ویڈیو تصاویر دکھانے کے لیے کون سا آؤٹ پٹ ڈیوائس استعمال ہوتا ہے؟
- Scanner
- Printer
- Projector
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
اینٹی وائرس سافٹ ویئر کا کیا کام ہے؟
- Protect against malware and viruses
- Manage email accounts
- Create and edit spreadsheets
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
کمپیوٹر کو ایک الیکٹرانک ڈیوائس کے طور پر کیسے بیان کیا جا سکتا ہے؟
- Carry out arithmetic operations
- Carry out logical operations
- Do complicated calculations
- Accept and process by implementation sequentially a set of stored instructions