Computer Science, asked by prototype88, 1 year ago

What is inheritance?tell me fast

Answers

Answered by Anonymous
1

Inheritance is property in which the property of a parent class(Superclass) is passed on to child class(Subclass). For example

class Abc{ —– This is a class

int a; —— This is a variable

public void abc(){} — Methods

}

class Xyz extends Abc —–(Extend is the keyword, Xyz is the subclass which inherits the properties of ABC parent class.)

{

public static void main (String args[]) ——- This is a method

{

Abc a= new Abc(); —— This is object creation where ‘a’ is the reference variable or object name

}

}


prototype88: woo
Answered by meeragupta0029
0

In object-oriented programming, inheritance is the mechanism of basing an object or class upon another object or class, retaining similar implementation. Also defined as deriving new classes from existing ones and forming them into a hierarchy of classes.

Similar questions