What's wrong with this example of Java property inheritance?

前端 未结 7 1382
天命终不由人
天命终不由人 2021-01-04 03:39

Inheritance.java

public class InheritanceExample {
  static public void main(String[] args){
    Cat c = new Cat();
    System.out.println(c.speak());

            


        
相关标签:
7条回答
  • 2021-01-04 04:10

    The Java(TM) way is to declare the protected String getSound() in Animal.java and implement it in the subclasses.

    0 讨论(0)
提交回复
热议问题