What is Inheritance? explain...
Answers
Answered by
1
- ɪɴʜᴇʀɪᴛᴀɴᴄᴇ ɪs ᴀ ᴍᴇᴄʜᴀɴɪsᴍ ɪɴ ᴡʜɪᴄʜ ᴏɴᴇ ᴄʟᴀss ᴀᴄǫᴜɪʀᴇs ᴛʜᴇ ᴘʀᴏᴘᴇʀᴛʏ ᴏғ ᴀɴᴏᴛʜᴇʀ ᴄʟᴀss. ғᴏʀ ᴇxᴀᴍᴘʟᴇ, ᴀ ᴄʜɪʟᴅ ɪɴʜᴇʀɪᴛs ᴛʜᴇ ᴛʀᴀɪᴛs ᴏғ ʜɪs/ʜᴇʀ ᴘᴀʀᴇɴᴛs. ᴡɪᴛʜ ɪɴʜᴇʀɪᴛᴀɴᴄᴇ, ᴡᴇ ᴄᴀɴ ʀᴇᴜsᴇ ᴛʜᴇ ғɪᴇʟᴅs ᴀɴᴅ ᴍᴇᴛʜᴏᴅs ᴏғ ᴛʜᴇ ᴇxɪsᴛɪɴɢ ᴄʟᴀss. ʜᴇɴᴄᴇ, ɪɴʜᴇʀɪᴛᴀɴᴄᴇ ғᴀᴄɪʟɪᴛᴀᴛᴇs ʀᴇᴜsᴀʙɪʟɪᴛʏ ᴀɴᴅ ɪs ᴀɴ ɪᴍᴘᴏʀᴛᴀɴᴛ ᴄᴏɴᴄᴇᴘᴛ ᴏғ ᴏᴏᴘs.
Answered by
1
Answer:
Inheritance is a mechanism in which one class acquires the property of another class. For example, a child inherits the traits of his/her parents. With inheritance, we can reuse the fields and methods of the existing class. Hence, inheritance facilitates Reusability and is an important concept of OOPs.
follow me i will follow back
Similar questions