【问题标题】:Polymorphism Concept: Mentioned example is of Method Overloading or Overriding? [duplicate]多态概念:提到的例子是方法重载还是覆盖? [复制]
【发布时间】:2018-03-14 01:04:59
【问题描述】:

下面的例子属于哪个概念:方法重载还是方法覆盖???

package com.java.inheritance;
class A {
public void display(Integer i)
{
    System.out.println("in display of A"+i);
}
}

class B extends  A
{
    public void display(String i)
    {
        System.out.println("in display of B class"+i);
    }
}
/*public class InheritanceDemo{
    public static void main(String args[])
    {
        A a=new B();
        a.display("suchi");
    }
}*/

请提出解释。

【问题讨论】:

标签: java polymorphism


【解决方案1】:

这是一个重载示例,因为您正在应用相同的 signature except the number/kind of parameter(s)

如果它具有完全相同的签名,它将被覆盖。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-05
    • 1970-01-01
    • 2021-09-30
    • 1970-01-01
    • 2016-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多