# Inherit / extend class calls constructor

**URL:** <https://forum.kirupa.com/t/inherit-extend-class-calls-constructor/254960>\
**Category:** Uncategorized\
**Created:** [March 17, 2008, 6:57pm UTC](https://forum.kirupa.com/t/inherit-extend-class-calls-constructor/254960 "2008-03-17T18:57:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![waffe](https://avatars.discourse-cdn.com/v4/letter/w/c37758/32.png) [@waffe](https://forum.kirupa.com/u/waffe)\
**Post date:** [March 17, 2008, 6:57pm UTC](https://forum.kirupa.com/t/inherit-extend-class-calls-constructor/254960/1 "2008-03-17T18:57:40Z")

</div>

Hi,

Class A extends class B like so:

public class A extends B{}

Why is class B’s constructor called? I thought when A extends B, A gets all of B’s methods and variables, great; but I don’t need the constructor called because class B has already been created. I just want class A to inherit all of B’s methods and variables. Can a class have two constructors, so when I extend class B an empty constructor is called but when I instantiate it the constructor with code is called?

I feel like I’m missing something here. :puzzled:

Thanks,  
waffe
