Can you override a private method in Java 2024?

Zoe Wilson | 2023-05-05 12:30:15 | page views:1699
I'll answer
Earn 20 gold coins for an accepted answer.20 Earn 20 gold coins for an accepted answer.
40more

Benjamin Stewart

Works at the International Air Transport Association, Lives in Montreal, Canada.
No, a private method cannot be overridden since it is not visible from any other class. You have declared a new method for your subclass that has no relation to the superclass method. One way to look at it is to ask yourself whether it would be legal to write super.func() in the Derived class.
2023-05-12 12:30:15

Charlotte Ross

QuesHub.com delivers expert answers and knowledge to you.
No, a private method cannot be overridden since it is not visible from any other class. You have declared a new method for your subclass that has no relation to the superclass method. One way to look at it is to ask yourself whether it would be legal to write super.func() in the Derived class.
ask:3,asku:1,askr:137,askz:21,askd:152,RedisW:0askR:3,askD:0 mz:hit,askU:0,askT:0askA:4