Passing different type than parameter type

前端 未结 4 382
庸人自扰
庸人自扰 2021-01-07 08:50

If I would have a variable a declared by A a and a method m with void m(B b). Is there any way that calling m(a)

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-07 09:09

    This can be possible when A is a subclass of B or we can say A extends B, this is known as inheritance in programming language, in this A will be a child of the class B and inherit all its properties

    you can check it from the link below

    https://www.tutorialspoint.com/java/java_inheritance.htm

提交回复
热议问题