Does the parent class of the Java subclass conflict with the method/function of the interface to be implemented? java Functions
The answer is, no. Child classes give priority to the methods that implement the parent class, although the methods of the parent class are exactly the same as those of interfaces.
Class father {public void f () {}} interface sameInterface {public void f ();} class son extends father implements sameInterface {public void f () {// This function actually implements f () of the parent class, rather than f () of the interface ()}}
Note: This overlap may conflict when both the parent class and the interface declare that an exception is thrown. For example, the parent class declares exception 1 and the interface declares exception 2. When sub-classes implement member functions, exception 1 or exception 2 cannot be implemented. You can only choose not to implement exceptions.
Class exception1 extends Exception {} class exception2 extends Exception {} class father {public void f () throws exception1 {}} interface sameInterface {public void f () throws exception2 ;} class son extends father implements sameInterface {public void f () {// you can only choose not to implement exceptions. An error will be reported when prediction1 or prediction2 is implemented }}