Constructors are functions without return types
Answers
Answered by
0
Answer:
ɴᴏ, ᴄᴏɴsᴛʀᴜᴄᴛᴏʀ ᴅᴏᴇs ɴᴏᴛ ʜᴀᴠᴇ ᴀɴʏ ʀᴇᴛᴜʀɴ ᴛʏᴘᴇ ɪɴ ᴊᴀᴠᴀ. ᴄᴏɴsᴛʀᴜᴄᴛᴏʀ ʟᴏᴏᴋs ʟɪᴋᴇ ᴍᴇᴛʜᴏᴅ ʙᴜᴛ ɪᴛ ɪs ɴᴏᴛ. ɪᴛ ᴅᴏᴇs ɴᴏᴛ ʜᴀᴠᴇ ᴀ ʀᴇᴛᴜʀɴ ᴛʏᴘᴇ ᴀɴᴅ ɪᴛs ɴᴀᴍᴇ ɪs sᴀᴍᴇ ᴀs ᴛʜᴇ ᴄʟᴀss ɴᴀᴍᴇ. ᴍᴏsᴛʟʏ ɪᴛ ɪs ᴜsᴇᴅ ᴛᴏ ɪɴsᴛᴀɴᴛɪᴀᴛᴇ ᴛʜᴇ ɪɴsᴛᴀɴᴄᴇ ᴠᴀʀɪᴀʙʟᴇs ᴏғ ᴀ ᴄʟᴀss.
Answered by
3
Answer:
No, constructor does not have any return type in Java. Constructor looks like method but it is not. It does not have a return type and its name is same as the class name. Mostly it is used to instantiate the instance variables of a class.
Similar questions