Inheritance Taking All The Properties and Behavior of Super Class To A Sub Class by Using Extends Keyword Is Called As Inheritance
Inheritance Taking All The Properties and Behavior of Super Class To A Sub Class by Using Extends Keyword Is Called As Inheritance
Relationships
Inheritance
Taking all the properties and behavior of super
class to a sub class by using extends keyword is
called as inheritance
extends
syntax
class sub_class_name extends super_class_name
Inheritance Page 1
class sub_class_name extends super_class_name
NOTE:-if class doesn't extends any class then by default compiler will
extend Object class
note
constructer calling statement
this():-to call the constructer of same class
super():-to call the constructor immediate parent class constructor
object
ename
eid
sal
deptno
Emp
desg
work()
extends
domain
Inheritance Page 2
domain
TE
object
Emp
company
main()
method area
TE
main()
heap
object
object
work() main frame ename=punga
eid=1 ename=pungi
emp obj1= sal=35000 Emp eid=2
deptno=1 sal=30000 emp
TE obj2= desg="MTE" deptno=1
desg="MTE"
work() work()
object
domain="ecomerce"
stack memory/thread TE
Inheritance Page 3
extends
two-wheeler
showrrom
Inheritance Page 4
is it possible to inherit static members ? yes we can
imp
prove that static members also inheritable by using extends?
driver:- school
Inheritance Page 5
multi level inheritance
hierarchical inheritance
multiple inheritance
Inheritance Page 6
super keyword : it is used to access a members of super class
Diamond problem
Inheritance Page 7
Diamond problem :- it is a major problem accurse when we
try to inherit more than one parent/super classes
1) what is inheritance ?
flow defn
explain extends keyword
explain types
2) what is diamond problem
reasoon-1
reason-2
reason-3
3) difference between this() and super()
4) difference between this and super
Inheritance Page 9
Inheritance Page 10