I have an abstract class with an abstract method it’s signature is:
Do we need to declare override or virtual in implementing classes? In Java, there is no need to do any of these.
An abstract method is virtual by default, so you don’t have to mark it as virtual. In fact, you can’t.
If you want to override the method in a derived class, you must mark it as override, otherwise you are not overriding it but creating a different method with the same name.


In Java, there is no need to do any of these.
Because, in Java, all methods are virtual by default unless you mark them as final. In C#, all methods are non-virtual by default unless you mark them as virtual or abstract.
If you want to override the method in a derived class
If you want to override a virtual method, you mark it with override, unless the method comes from an interface.
Elaborating just a bit…
Why do we have to mark a virtual method implementation in a derived class with override at all, you might ask? Shouldn’t the compiler know the base class has a virtual method with that name and just do it?
In fact, the compiler does know, and will issue a warning if you implement a virtual/abstract method in a derived class without the ._3bX7W3J0lU78fp7cayvNxx{max-width:208px;text-align:center} ._1PeZajQI0Wm8P3B45yshR{fill:var(–newCommunityTheme-actionIcon)}._1PeZajQI0Wm8P3B45yshR._3axV0unm-cpsxoKWYwKh2x{fill:#ea0027} ._1x9diBHPBP-hL1JiwUwJ5J{font-size:14px;font-weight:500;line-height:18px;color:#ff585b;padding-left:3px;padding-right:24px}._2B0OHMLKb9TXNdd9g5Ere-,._1xKxnscCn2PjBiXhorZef4{height:16px;padding-right:4px;vertical-align:top}._1LLqoNXrOsaIkMtOuTBmO5{height:20px;padding-right:8px;vertical-align:bottom}.QB2Yrr8uihZVRhvwrKuMS{height:18px;padding-right:8px;vertical-align:top}._3w_KK8BUvCMkCPWZVsZQn0{font-size:14px;font-weight:500;line-height:18px;color:var(–newCommunityTheme-actionIcon)}._3w_KK8BUvCMkCPWZVsZQn0 ._1LLqoNXrOsaIkMtOuTBmO5,._3w_KK8BUvCMkCPWZVsZQn0 ._2B0OHMLKb9TXNdd9g5Ere-,._3w_KK8BUvCMkCPWZVsZQn0 ._1xKxnscCn2PjBiXhorZef4,._3w_KK8BUvCMkCPWZVsZQn0 .QB2Yrr8uihZVRhvwrKuMS{fill:var(–newCommunityTheme-actionIcon)} ._33axOHPa8DzNnTmwzen-wO{font-size:14px;font-weight:700;letter-spacing:.5px;line-height:32px;text-transform:uppercase;display:block;padding:0 16px;width:100%} .FIYolDqalszTnjjNfThfT{max-width:256px;white-space:normal;text-align:center} ._9ZuQyDXhFth1qKJF4KNm8{padding:12px 12px 40px}._2iNJX36LR2tMHx_unzEkVM,._1JmnMJclrTwTPpAip5U_Hm{font-size:16px;font-weight:500;line-height:20px;color:var(–newCommunityTheme-bodyText);margin-bottom:40px;padding-top:4px}._306gA2lxjCHX44ssikUp3O{margin-bottom:32px}._1Omf6afKRpv3RKNCWjIyJ4{font-size:18px;font-weight:500;line-height:22px;border-bottom:2px solid var(–newCommunityTheme-line);color:var(–newCommunityTheme-bodyText);margin-bottom:8px;padding-bottom:8px}._2Ss7VGMX-UPKt9NhFRtgTz{margin-bottom:24px}._3vWu4F9B4X4Yc-Gm86-FMP{border-bottom:1px solid var(–newCommunityTheme-line);margin-bottom:8px;padding-bottom:2px}._3vWu4F9B4X4Yc-Gm86-FMP:last-of-type{border-bottom-width:0}._2qAEe8HGjtHsuKsHqNCa9u{font-size:14px;font-weight:500;line-height:18px;color:var(–newCommunityTheme-bodyText);padding-bottom:8px;padding-top:8px}.c5RWd-O3CYE-XSLdTyjtI{padding:8px 0}._3whORKuQps-WQpSceAyHuF{font-size:12px;font-weight:400;line-height:16px;color:var(–newCommunityTheme-actionIcon);margin-bottom:8px}._1Qk-ka6_CJz1fU3OUfeznu{margin-bottom:8px}._3ds8Wk2l32hr3hLddQshhG{font-weight:500}._1h0r6vtgOzgWtu-GNBO6Yb,._3ds8Wk2l32hr3hLddQshhG{font-size:12px;line-height:16px;color:var(–newCommunityTheme-actionIcon)}._1h0r6vtgOzgWtu-GNBO6Yb{font-weight:400}.horIoLCod23xkzt7MmTpC{font-size:12px;font-weight:400;line-height:16px;color:#ea0027}._33Iw1wpNZ-uhC05tWsB9xi{margin-top:24px}._2M7LQbQxH40ingJ9h9RslL{font-size:12px;font-weight:400;line-height:16px;color:var(–newCommunityTheme-actionIcon);margin-bottom:8px} .s5ap8yh1b4ZfwxvHizW3f{color:var(–newCommunityTheme-metaText);padding-top:5px}.s5ap8yh1b4ZfwxvHizW3f._19JhaP1slDQqu2XgT3vVS0{color:#ea0027} ._1EPynDYoibfs7nDggdH7Gq{margin-bottom:8px;position:relative}._1EPynDYoibfs7nDggdH7Gq._3-0c12FCnHoLz34dQVveax{max-height:63px;overflow:hidden}._1zPvgKHteTOub9dKkvrOl4{font-family:Noto Sans,Arial,sans-serif;font-size:14px;line-height:21px;font-weight:400;word-wrap:break-word}._1dp4_svQVkkuV143AIEKsf{-ms-flex-align:baseline;align-items:baseline;background-color:var(–newCommunityTheme-body);bottom:-2px;display:-ms-flexbox;display:flex;-ms-flex-flow:row nowrap;flex-flow:row nowrap;padding-left:2px;position:absolute;right:-8px}._5VBcBVybCfosCzMJlXzC3{font-family:Noto Sans,Arial,sans-serif;font-size:14px;font-weight:400;line-height:21px;color:var(–newCommunityTheme-bodyText)}._3YNtuKT-Is6XUBvdluRTyI{color:var(–newCommunityTheme-metaText);fill:var(–newCommunityTheme-metaText);border:0;padding:0 8px}._3YNtuKT-Is6XUBvdluRTyI:active,._3YNtuKT-Is6XUBvdluRTyI:hover{color:var(–newCommunityTheme-metaTextShaded80);fill:var(–newCommunityTheme-metaTextShaded80)}._3YNtuKT-Is6XUBvdluRTyI:disabled,._3YNtuKT-Is6XUBvdluRTyI[data-disabled],._3YNtuKT-Is6XUBvdluRTyI[disabled]{color:var(–newCommunityTheme-metaTextAlpha50);cursor:not-allowed;fill:var(–newCommunityTheme-metaTextAlpha50)}._2ZTVnRPqdyKo1dA7Q7i4EL{transition:all .1s linear 0s}.k51Bu_pyEfHQF6AAhaKfS{transition:none}._2qi_L6gKnhyJ0ZxPmwbDFK{transition:all .1s linear 0s;display:block;background-color:var(–newCommunityTheme-field);border-radius:4px;padding:8px;margin-bottom:12px;margin-top:8px;border:1px solid var(–newCommunityTheme-canvas);cursor:pointer}._2qi_L6gKnhyJ0ZxPmwbDFK:focus{outline:none}._2qi_L6gKnhyJ0ZxPmwbDFK:hover{border:1px solid var(–newCommunityTheme-button)}._2qi_L6gKnhyJ0ZxPmwbDFK._3GG6tRGPPJiejLqt2AZfh4{transition:none;border:1px solid var(–newCommunityTheme-button)}.IzSmZckfdQu5YP9qCsdWO{cursor:pointer;transition:all .1s linear 0s}.IzSmZckfdQu5YP9qCsdWO ._1EPynDYoibfs7nDggdH7Gq{border:1px solid transparent;border-radius:4px;transition:all .1s linear 0s}.IzSmZckfdQu5YP9qCsdWO:hover ._1EPynDYoibfs7nDggdH7Gq{border:1px solid var(–newCommunityTheme-button);padding:4px}._1YvJWALkJ8iKZxUU53TeNO{font-size:12px;font-weight:700;line-height:16px;color:var(–newCommunityTheme-button)}._3adDzm8E3q64yWtEcs5XU7{display:-ms-flexbox;display:flex}._3adDzm8E3q64yWtEcs5XU7 ._3jyKpErOrdUDMh0RFq5V6f{-ms-flex:100%;flex:100%}._3adDzm8E3q64yWtEcs5XU7 .dqhlvajEe-qyxij0jNsi0{color:var(–newCommunityTheme-button)}._3adDzm8E3q64yWtEcs5XU7 ._12nHw-MGuz_r1dQx5YPM2v,._3adDzm8E3q64yWtEcs5XU7 .dqhlvajEe-qyxij0jNsi0{font-size:12px;font-weight:700;line-height:16px;cursor:pointer;-ms-flex-item-align:end;align-self:flex-end;-webkit-user-select:none;-ms-user-select:none;user-select:none}._3adDzm8E3q64yWtEcs5XU7 ._12nHw-MGuz_r1dQx5YPM2v{color:var(–newCommunityTheme-button);margin-right:8px;color:var(–newCommunityTheme-errorText)}._3zTJ9t4vNwm1NrIaZ35NS6{font-family:Noto Sans,Arial,sans-serif;font-size:14px;line-height:21px;font-weight:400;word-wrap:break-word;width:100%;padding:0;border:none;background-color:transparent;resize:none;outline:none;cursor:pointer;color:var(–newRedditTheme-bodyText)}._2JIiUcAdp9rIhjEbIjcuQ-{resize:none;cursor:auto}._2I2LpaEhGCzQ9inJMwliNO{display:inline-block}._2I2LpaEhGCzQ9inJMwliNO,._42Nh7O6pFcqnA6OZd3bOK{margin-left:4px;vertical-align:middle}._42Nh7O6pFcqnA6OZd3bOK{fill:var(–newCommunityTheme-button);height:16px;width:16px;margin-bottom:2px} ._2cHgYGbfV9EZMSThqLt2tx{margin-bottom:16px;border-radius:4px}._3Q7WCNdCi77r0_CKPoDSFY{width:75%;height:24px}._2wgLWvNKnhoJX3DUVT_3F-,._3Q7WCNdCi77r0_CKPoDSFY{background:var(–newCommunityTheme-field);background-size:200%;margin-bottom:16px;border-radius:4px}._2wgLWvNKnhoJX3DUVT_3F-{width:100%;height:46px} .Rd5g7JmL4Fdk-aZi1-U_V{transition:all .1s linear 0s}._2TMXtA984ePtHXMkOpHNQm{font-size:16px;font-weight:500;line-height:20px;margin-bottom:4px}.CneW1mCG4WJXxJbZl5tzH{border-top:1px solid var(–newRedditTheme-line);margin-top:16px;padding-top:16px}._11ARF4IQO4h3HeKPpPg0xb{transition:all .1s linear 0s;display:none;fill:var(–newCommunityTheme-button);height:16px;width:16px;vertical-align:middle;margin-bottom:2px;margin-left:4px;cursor:pointer}._1I3N-uBrbZH-ywcmCnwv_B:hover ._11ARF4IQO4h3HeKPpPg0xb{display:inline-block}._33CSUrVoafEXJUDX3qOQtf{height:12px;width:12px;margin-bottom:2px;margin-right:4px;vertical-align:middle;fill:var(–newRedditTheme-metaText)}._2IvhQwkgv_7K0Q3R0695Cs{border-radius:4px;border:1px solid var(–newCommunityTheme-line)}._2IvhQwkgv_7K0Q3R0695Cs:focus{outline:none}._1I3N-uBrbZH-ywcmCnwv_B{transition:all .1s linear 0s;border-radius:4px;border:1px solid var(–newCommunityTheme-line)}._1I3N-uBrbZH-ywcmCnwv_B:focus{outline:none}._1I3N-uBrbZH-ywcmCnwv_B.IeceazVNz_gGZfKXub0ak,._1I3N-uBrbZH-ywcmCnwv_B:hover{border:1px solid var(–newCommunityTheme-button)}._35hmSCjPO8OEezK36eUXpk._35hmSCjPO8OEezK36eUXpk._35hmSCjPO8OEezK36eUXpk{margin-top:25px;left:-9px}._3aEIeAgUy9VfJyRPljMNJP._3aEIeAgUy9VfJyRPljMNJP._3aEIeAgUy9VfJyRPljMNJP,._3aEIeAgUy9VfJyRPljMNJP._3aEIeAgUy9VfJyRPljMNJP._3aEIeAgUy9VfJyRPljMNJP:focus-within,._3aEIeAgUy9VfJyRPljMNJP._3aEIeAgUy9VfJyRPljMNJP._3aEIeAgUy9VfJyRPljMNJP:hover{transition:all .1s linear 0s;border:none;padding:8px 8px 0}._25yWxLGH4C6j26OKFx8kD5{display:inline}._1i46tE0yFLStZBdRfHnYIa{-ms-flex-align:center;align-items:center;margin-top:4px;margin-bottom:8px}._2YsVWIEj0doZMxreeY6iDG,._1i46tE0yFLStZBdRfHnYIa{font-size:12px;font-weight:400;line-height:16px;color:var(–newCommunityTheme-metaText);display:-ms-flexbox;display:flex}._2YsVWIEj0doZMxreeY6iDG{padding:4px 6px}._1hFCAcL4_gkyWN0KM96zgg{color:var(–newCommunityTheme-button);margin-right:8px;margin-left:auto;color:var(–newCommunityTheme-errorText)}._1hFCAcL4_gkyWN0KM96zgg,._1dF0IdghIrnqkJiUxfswxd{font-size:12px;font-weight:700;line-height:16px;cursor:pointer;-ms-flex-item-align:end;align-self:flex-end;-webkit-user-select:none;-ms-user-select:none;user-select:none}._1dF0IdghIrnqkJiUxfswxd{color:var(–newCommunityTheme-button)}._3VGrhUu842I3acqBMCoSAq{font-weight:700;color:#ff4500;text-transform:uppercase;margin-right:4px}._3VGrhUu842I3acqBMCoSAq,.edyFgPHILhf5OLH2vk-tk{font-size:12px;line-height:16px}.edyFgPHILhf5OLH2vk-tk{font-weight:400;-ms-flex-preferred-size:100%;flex-basis:100%;margin-bottom:4px;color:var(–newCommunityTheme-metaText)}._19lMIGqzfTPVY3ssqTiZSX._19lMIGqzfTPVY3ssqTiZSX._19lMIGqzfTPVY3ssqTiZSX{margin-top:6px}._19lMIGqzfTPVY3ssqTiZSX._19lMIGqzfTPVY3ssqTiZSX._19lMIGqzfTPVY3ssqTiZSX._3MAHaXXXXi9Xrmc_oMPTdP{margin-top:4px} .ehsOqYO6dxn_Pf9Dzwu37{margin-top:0;overflow:visible}._2pFdCpgBihIaYh9DSMWBIu{height:24px}._2pFdCpgBihIaYh9DSMWBIu.uMPgOFYlCc5uvpa2Lbteu{border-radius:2px}._2pFdCpgBihIaYh9DSMWBIu.uMPgOFYlCc5uvpa2Lbteu:focus,._2pFdCpgBihIaYh9DSMWBIu.uMPgOFYlCc5uvpa2Lbteu:hover{background-color:var(–newRedditTheme-navIconFaded10);outline:none}._38GxRFSqSC-Z2VLi5Xzkjy{color:var(–newCommunityTheme-actionIcon)}._2DO72U0b_6CUw3msKGrnnT{border-top:none;color:var(–newCommunityTheme-metaText);cursor:pointer;padding:8px 16px 8px 8px;text-transform:none}._2DO72U0b_6CUw3msKGrnnT:hover{background-color:#0079d3;border:none;color:var(–newCommunityTheme-body);fill:var(–newCommunityTheme-body)} ._1zyZUfB30L-DDI98CCLJlQ{border:1px solid transparent;display:block;padding:0 16px;width:100%;border:1px solid var(–newCommunityTheme-body);border-radius:4px;box-sizing:border-box}._1zyZUfB30L-DDI98CCLJlQ:hover{background-color:var(–newCommunityTheme-primaryButtonTintedEighty)}._1zyZUfB30L-DDI98CCLJlQ._2FebEA49ReODemDlwzYHSR,._1zyZUfB30L-DDI98CCLJlQ:active,._1zyZUfB30L-DDI98CCLJlQ:hover{color:var(–newCommunityTheme-bodyText);fill:var(–newCommunityTheme-bodyText)}._1zyZUfB30L-DDI98CCLJlQ._2FebEA49ReODemDlwzYHSR,._1zyZUfB30L-DDI98CCLJlQ:active{background-color:var(–newCommunityTheme-primaryButtonShadedEighty)}._1zyZUfB30L-DDI98CCLJlQ:disabled,._1zyZUfB30L-DDI98CCLJlQ[data-disabled],._1zyZUfB30L-DDI98CCLJlQ[disabled]{background-color:var(–newCommunityTheme-primaryButtonTintedFifty);color:rgba(var(–newCommunityTheme-bodyText),.5);fill:rgba(var(–newCommunityTheme-bodyText),.5);cursor:not-allowed}._1zyZUfB30L-DDI98CCLJlQ:active,._1zyZUfB30L-DDI98CCLJlQ:disabled,._1zyZUfB30L-DDI98CCLJlQ:hover,._1zyZUfB30L-DDI98CCLJlQ[data-disabled],._1zyZUfB30L-DDI98CCLJlQ[disabled]{border:1px solid var(–newCommunityTheme-body)}._1O2i-ToERP3a0i4GSL0QwU,._1uBzAtenMgErKev3G7oXru{display:block;fill:var(–newCommunityTheme-body);height:22px;width:22px}._1O2i-ToERP3a0i4GSL0QwU._2ilDLNSvkCHD3Cs9duy9Q_,._1uBzAtenMgErKev3G7oXru._2ilDLNSvkCHD3Cs9duy9Q_{height:14px;width:14px}._2kBlhw4LJXNnk73IJcwWsT,._1kRJoT0CagEmHsFjl2VT4R{height:24px;padding:0;width:24px}._2kBlhw4LJXNnk73IJcwWsT._2ilDLNSvkCHD3Cs9duy9Q_,._1kRJoT0CagEmHsFjl2VT4R._2ilDLNSvkCHD3Cs9duy9Q_{height:14px;width:14px}._3VgTjAJVNNV7jzlnwY-OFY{font-size:14px;line-height:32px;padding:0 16px}._3VgTjAJVNNV7jzlnwY-OFY,._3VgTjAJVNNV7jzlnwY-OFY._2ilDLNSvkCHD3Cs9duy9Q_{font-weight:700;letter-spacing:.5px;text-transform:uppercase}._3VgTjAJVNNV7jzlnwY-OFY._2ilDLNSvkCHD3Cs9duy9Q_{font-size:12px;line-height:24px;padding:4px 9px 2px;width:100%}._2QmHYFeMADTpuXJtd36LQs{font-size:14px;line-height:32px;padding:0 16px}._2QmHYFeMADTpuXJtd36LQs,._2QmHYFeMADTpuXJtd36LQs._2ilDLNSvkCHD3Cs9duy9Q_{font-weight:700;letter-spacing:.5px;text-transform:uppercase}._2QmHYFeMADTpuXJtd36LQs._2ilDLNSvkCHD3Cs9duy9Q_{font-size:12px;line-height:24px;padding:4px 9px 2px;width:100%}._2QmHYFeMADTpuXJtd36LQs:hover ._31L3r0EWsU0weoMZvEJcUA{display:none}._2QmHYFeMADTpuXJtd36LQs ._31L3r0EWsU0weoMZvEJcUA,._2QmHYFeMADTpuXJtd36LQs:hover ._11Zy7Yp4S1ZArNqhUQ0jZW{display:block}._2QmHYFeMADTpuXJtd36LQs ._11Zy7Yp4S1ZArNqhUQ0jZW{display:none}._2CLbCoThTVSANDpeJGlI6a{width:100%}._2CLbCoThTVSANDpeJGlI6a:hover ._31L3r0EWsU0weoMZvEJcUA{display:none}._2CLbCoThTVSANDpeJGlI6a ._31L3r0EWsU0weoMZvEJcUA,._2CLbCoThTVSANDpeJGlI6a:hover ._11Zy7Yp4S1ZArNqhUQ0jZW{display:block}._2CLbCoThTVSANDpeJGlI6a ._11Zy7Yp4S1ZArNqhUQ0jZW{display:none} ._3Im6OD67aKo33nql4FpSp_{border:1px solid var(–newCommunityTheme-widgetColors-sidebarWidgetBorderColor);border-radius:5px 5px 4px 4px;overflow:visible;word-wrap:break-word;background-color:var(–newCommunityTheme-body);padding:12px}.lnK0-OzG7nLFydTWuXGcY{font-size:10px;font-weight:700;letter-spacing:.5px;line-height:12px;text-transform:uppercase;padding-bottom:4px;color:var(–newCommunityTheme-navIcon)} ._12xlue8dQ1odPw1J81FIGQ{display:inline-block;vertical-align:middle} ._3-SW6hQX6gXK9G4FM74obr{display:inline-block;vertical-align:text-bottom;width:16px;height:16px;font-size:16px;line-height:16px} ._37coyt0h8ryIQubA7RHmUc{margin-top:12px;padding-top:12px}._2XJvPvYIEYtcS4ORsDXwa3{border-radius:100%;box-sizing:border-box;-ms-flex:none;flex:none;margin-right:8px}._2Vkdik1Q8k0lBEhhA_lRKE{height:54px;width:54px}.eGjjbHtkgFc-SYka3LM3M,._2Vkdik1Q8k0lBEhhA_lRKE{border-radius:100%;box-sizing:border-box;-ms-flex:none;flex:none;margin-right:8px;background-position:50%;background-repeat:no-repeat;background-size:100%}.eGjjbHtkgFc-SYka3LM3M{height:36px;width:36px}.j9k2MUR13FjoBBeLo1C1m{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;margin-top:13px;margin-bottom:2px}._3Evl5aOozId3QVjs7iry2c{font-size:12px;font-weight:400;line-height:16px;margin-right:4px;margin-left:4px}._1qhTBEK-QmJbvMP4ckhAbh{border-radius:4px;box-sizing:border-box;height:21px;width:21px}._1qhTBEK-QmJbvMP4ckhAbh:nth-child(2),._1qhTBEK-QmJbvMP4ckhAbh:nth-child(3){margin-left:-9px}._3nzVPnRRnrls4DOXO_I0fn{margin:auto 0 auto auto;padding-top:10px;vertical-align:middle}._3nzVPnRRnrls4DOXO_I0fn ._1LAmcxBaaqShJsi8RNT-Vp i{color:unset}._2bWoGvMqVhMWwhp4Pgt4LP{margin:16px 0;font-size:12px;font-weight:400;line-height:16px}.tWeTbHFf02PguTEonwJD0{font-size:16px;margin-right:4px}._2AbGMsrZJPHrLm9e-oyW1E{width:180px;text-align:center}._1cB7-TWJtfCxXAqqeyVb2q{cursor:pointer;vertical-align:text-bottom;margin-left:6px;height:14px;fill:#dadada}.hpxKmfWP2ZiwdKaWpefMn{background-color:var(–newCommunityTheme-active);background-size:cover;background-image:var(–newCommunityTheme-banner-backgroundImage);background-position-y:center;background-position-x:center;background-repeat:no-repeat;border-radius:3px 3px 0 0;height:34px;margin:-12px -12px 10px}._20Kb6TX_CdnePoT8iEsls6{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;margin-bottom:8px}._20Kb6TX_CdnePoT8iEsls6>*{display:inline-block;vertical-align:middle}.t9oUK2WY0d28lhLAh3N5q{margin-top:-23px}._2KqgQ5WzoQRJqjjoznu22o{display:inline-block;-ms-flex-negative:0;flex-shrink:0;position:relative}._2D7eYuDY6cYGtybECmsxvE{-ms-flex:1 1 auto;flex:1 1 auto;overflow:hidden;text-overflow:ellipsis}._2D7eYuDY6cYGtybECmsxvE:hover{text-decoration:underline}._19bCWnxeTjqzBElWZfIlJb{font-size:16px;font-weight:500;line-height:20px;display:inline-block}._2TC7AdkcuxFIFKRO_VWis8{margin-left:10px;margin-top:30px}._2TC7AdkcuxFIFKRO_VWis8._35WVFxUni5zeFkPk7O4iiB{margin-top:35px}._7kAMkb9SAVF8xJ3L53gcW{display:-ms-flexbox;display:flex;margin-bottom:8px}._7kAMkb9SAVF8xJ3L53gcW>*{-ms-flex:auto;flex:auto}._1LAmcxBaaqShJsi8RNT-Vp{padding:0 2px 0 4px;vertical-align:middle}._3_HlHJ56dAfStT19Jgl1bF,.nEdqRRzLEN43xauwtgTmj{padding-right:4px}._3_HlHJ56dAfStT19Jgl1bF{padding-left:16px}._2QZ7T4uAFMs_N83BZcN-Em{font-family:Noto Sans,Arial,sans-serif;font-size:14px;font-weight:400;line-height:18px;display:-ms-flexbox;display:flex;-ms-flex-flow:row nowrap;flex-flow:row nowrap}._19sQCxYe2NApNbYNX5P5-L{cursor:default;height:16px;margin-right:8px;width:16px}._3XFx6CfPlg-4Usgxm0gK8R{font-size:16px;font-weight:500;line-height:20px}._34InTQ51PAhJivuc_InKjJ{color:var(–newCommunityTheme-actionIcon)}._29_mu5qI8E1fq6Uq5koje8{font-size:12px;font-weight:500;line-height:16px;display:inline-block;word-break:break-word}._2BY2-wxSbNFYqAy98jWyTC{margin-top:10px}._3sGbDVmLJd_8OV8Kfl7dVv{font-family:Noto Sans,Arial,sans-serif;font-size:14px;font-weight:400;line-height:21px;margin-top:8px;word-wrap:break-word}._1qiHDKK74j6hUNxM0p9ZIp{margin-top:12px}.isNotInButtons2020 ._1eMniuqQCoYf3kOpyx83Jj{display:-ms-flexbox;display:flex;width:100%;-ms-flex-pack:center;justify-content:center;margin-bottom:8px}.isNotInButtons2020 ._326PJFFRv8chYfOlaEYmGt{display:-ms-flexbox;display:flex}.isNotInButtons2020 .Jy6FIGP1NvWbVjQZN7FHA,.isNotInButtons2020 ._326PJFFRv8chYfOlaEYmGt{width:100%;font-size:14px;font-weight:700;letter-spacing:.5px;line-height:32px;text-transform:uppercase;-ms-flex-pack:center;justify-content:center;padding:0 16px}.isNotInButtons2020 .Jy6FIGP1NvWbVjQZN7FHA{display:block;margin-top:11px}.isNotInButtons2020 ._1cDoUuVvel5B1n5wa3K507{display:block;padding:0 16px;width:100%;font-size:14px;font-weight:700;letter-spacing:.5px;line-height:32px;text-transform:uppercase;-ms-flex-pack:center;justify-content:center;margin-top:11px;text-transform:unset}.isInButtons2020 .Jy6FIGP1NvWbVjQZN7FHA,.isInButtons2020 ._326PJFFRv8chYfOlaEYmGt,.isInButtons2020 ._1eMniuqQCoYf3kOpyx83Jj,.isInButtons2020 ._1cDoUuVvel5B1n5wa3K507{-ms-flex-pack:center;justify-content:center;margin-top:12px;width:100%}._2_w8DCFR-DCxgxlP1SGNq5{margin-right:4px;vertical-align:middle}._1aS-wQ7rpbcxKT0d5kjrbh{border-radius:4px;display:inline-block;padding:4px}._2cn386lOe1A_DTmBUA-qSM{border-top:1px solid var(–newCommunityTheme-widgetColors-lineColor);margin-top:10px}._2Zdkj7cQEO3zSGHGK2XnZv{display:inline-block}.wzFxUZxKK8HkWiEhs0tyE{font-size:12px;font-weight:700;line-height:16px;color:var(–newCommunityTheme-button);cursor:pointer;text-align:left;margin-top:2px}._3R24jLERJTaoRbM_vYd9v0._3R24jLERJTaoRbM_vYd9v0._3R24jLERJTaoRbM_vYd9v0{display:none}._38lwnrIpIyqxDfAF1iwhcV{background-color:var(–newRedditTheme-line);border:none;height:1px;margin:16px 0}.yobE-ux_T1smVDcFMMKFv{font-size:16px;font-weight:500;line-height:20px}._2DVpJZAGplELzFy4mB0epQ{margin-top:8px}._2DVpJZAGplELzFy4mB0epQ .x1f6lYW8eQcUFu0VIPZzb{color:inherit}._2DVpJZAGplELzFy4mB0epQ svg.LTiNLdCS1ZPRx9wBlY2rD{fill:inherit;padding-right:8px}._2DVpJZAGplELzFy4mB0epQ ._18e78ihYD3tNypPhtYISq3{font-family:Noto Sans,Arial,sans-serif;font-size:14px;font-weight:400;line-height:18px;color:inherit} .LalRrQILNjt65y-p-QlWH{fill:var(–newRedditTheme-actionIcon);height:18px;width:18px}.LalRrQILNjt65y-p-QlWH rect{stroke:var(–newRedditTheme-metaText)}._3J2-xIxxxP9ISzeLWCOUVc{height:18px}.FyLpt0kIWG1bTDWZ8HIL1{margin-top:4px}._2ntJEAiwKXBGvxrJiqxx_2,._1SqBC7PQ5dMOdF0MhPIkA8{height:24px;vertical-align:middle;width:24px}._1SqBC7PQ5dMOdF0MhPIkA8{-ms-flex-align:center;align-items:center;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:center;justify-content:center} ._2a172ppKObqWfRHr8eWBKV{-ms-flex-negative:0;flex-shrink:0;margin-right:8px}._39-woRduNuowN7G4JTW4I8{border-top:1px solid var(–newCommunityTheme-widgetColors-lineColor);margin-top:12px;padding-top:12px}._3AOoBdXa2QKVKqIEmG7Vkb{font-size:12px;font-weight:400;line-height:16px;-ms-flex-align:center;align-items:center;background-color:var(–newCommunityTheme-body);border-radius:4px;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;margin-top:12px}.vzEDg-tM8ZDpEfJnbaJuU{color:var(–newCommunityTheme-button);fill:var(–newCommunityTheme-button);height:14px;width:14px}.r51dfG6q3N-4exmkjHQg_{font-size:10px;font-weight:700;letter-spacing:.5px;line-height:12px;text-transform:uppercase;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between}._2ygXHcy_x6RG74BMk0UKkN{margin-left:8px}._2BnLYNBALzjH6p_ollJ-RF{display:-ms-flexbox;display:flex;margin-left:auto}._1-25VxiIsZFVU88qFh-T8p{padding:0}._3BmRwhm18nr4GmDhkoSgtb{color:var(–newCommunityTheme-bodyText);-ms-flex:0 0 auto;flex:0 0 auto;line-height:16px} ._3Qx5bBCG_O8wVZee9J-KyJ{border-top:1px solid var(–newRedditTheme-line);margin-top:16px;padding-top:16px}._3Qx5bBCG_O8wVZee9J-KyJ ._2NbKFI9n3wPM76pgfAPEsN{margin:0;padding:0}._3Qx5bBCG_O8wVZee9J-KyJ ._2NbKFI9n3wPM76pgfAPEsN ._2btz68cXFBI3RWcfSNwbmJ{font-family:Noto Sans,Arial,sans-serif;font-size:14px;font-weight:400;line-height:21px;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;margin:8px 0}._3Qx5bBCG_O8wVZee9J-KyJ ._2NbKFI9n3wPM76pgfAPEsN ._2btz68cXFBI3RWcfSNwbmJ.QgBK4ECuqpeR2umRjYcP2{opacity:.4}._3Qx5bBCG_O8wVZee9J-KyJ ._2NbKFI9n3wPM76pgfAPEsN ._2btz68cXFBI3RWcfSNwbmJ label{font-size:12px;font-weight:500;line-height:16px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}._3Qx5bBCG_O8wVZee9J-KyJ ._2NbKFI9n3wPM76pgfAPEsN ._2btz68cXFBI3RWcfSNwbmJ label svg{fill:currentColor;height:20px;margin-right:4px;width:20px}._3Qx5bBCG_O8wVZee9J-KyJ ._4OtOUaGIjjp2cNJMUxme_{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;padding:0;width:100%}._3Qx5bBCG_O8wVZee9J-KyJ ._4OtOUaGIjjp2cNJMUxme_ svg{display:inline-block;height:12px;width:12px}.isInButtons2020 ._4OtOUaGIjjp2cNJMUxme_{padding:0 12px}.isInButtons2020 ._1ra1vBLrjtHjhYDZ_gOy8F{font-family:Noto Sans,Arial,sans-serif;font-size:12px;font-weight:700;letter-spacing:unset;line-height:16px;text-transform:unset}._1ra1vBLrjtHjhYDZ_gOy8F{–textColor:var(–newCommunityTheme-widgetColors-sidebarWidgetTextColor);–textColorHover:var(–newCommunityTheme-widgetColors-sidebarWidgetTextColorShaded80);font-size:10px;font-weight:700;letter-spacing:.5px;line-height:12px;text-transform:uppercase;color:var(–textColor);fill:var(–textColor);opacity:1}._1ra1vBLrjtHjhYDZ_gOy8F._2UlgIO1LIFVpT30ItAtPfb{–textColor:var(–newRedditTheme-widgetColors-sidebarWidgetTextColor);–textColorHover:var(–newRedditTheme-widgetColors-sidebarWidgetTextColorShaded80)}._1ra1vBLrjtHjhYDZ_gOy8F:active,._1ra1vBLrjtHjhYDZ_gOy8F:hover{color:var(–textColorHover);fill:var(–textColorHover)}._1ra1vBLrjtHjhYDZ_gOy8F:disabled,._1ra1vBLrjtHjhYDZ_gOy8F[data-disabled],._1ra1vBLrjtHjhYDZ_gOy8F[disabled]{opacity:.5;cursor:not-allowed} .c_dVyWK3BXRxSN3ULLJ_t{border-radius:4px 4px 0 0;height:34px;left:0;position:absolute;right:0;top:0}._1OQL3FCA9BfgI57ghHHgV3{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-pack:start;justify-content:flex-start;margin-top:32px}._1OQL3FCA9BfgI57ghHHgV3 ._33jgwegeMTJ-FJaaHMeOjV{border-radius:9001px;height:32px;width:32px}._1OQL3FCA9BfgI57ghHHgV3 ._1wQQNkVR4qNpQCzA19X4B6{height:16px;margin-left:8px;width:200px}._39IvqNe6cqNVXcMFxFWFxx{display:-ms-flexbox;display:flex;margin:12px 0}._39IvqNe6cqNVXcMFxFWFxx ._29TSdL_ZMpyzfQ_bfdcBSc{-ms-flex:1;flex:1}._39IvqNe6cqNVXcMFxFWFxx .JEV9fXVlt_7DgH-zLepBH{height:18px;width:50px}._39IvqNe6cqNVXcMFxFWFxx ._3YCOmnWpGeRBW_Psd5WMPR{height:12px;margin-top:4px;width:60px}._2iO5zt81CSiYhWRF9WylyN{height:18px;margin-bottom:4px}._2iO5zt81CSiYhWRF9WylyN._2E9u5XvlGwlpnzki78vasG{width:230px}._2iO5zt81CSiYhWRF9WylyN.fDElwzn43eJToKzSCkejE{width:100%}._2iO5zt81CSiYhWRF9WylyN._2kNB7LAYYqYdyS85f8pqfi{width:250px}._2iO5zt81CSiYhWRF9WylyN._1XmngqAPKZO_1lDBwcQrR7{width:120px}._3XbVvl-zJDbcDeEdSgxV4_{border-radius:4px;height:32px;margin-top:16px;width:100%}._2hgXdc8jVQaXYAXvnqEyED{animation:_3XkHjK4wMgxtjzC1TvoXrb 1.5s ease infinite;background:linear-gradient(90deg,var(–newCommunityTheme-field),var(–newCommunityTheme-inactive),var(–newCommunityTheme-field));background-size:200%}._1KWSZXqSM_BLhBzkPyJFGR{background-color:var(–newCommunityTheme-widgetColors-sidebarWidgetBackgroundColor);border-radius:4px;padding:12px;position:relative;width:auto} /*# sourceMappingURL=https://www.redditstatic.com/desktop2x/chunkCSS/IdCard.8fe90067a922ef36d4b6.css.map*/override keyword. But consider the case where the method in the derived class was there first!
Imagine you started with a Dog class that didn’t have a Bark() method at all, and a Yorkie class that had public void Bark() { WriteLine("Yip!!!"); } Existing code uses Yorkie.Bark() explicitly. Someone else looks at the Dog class and thinks, “this should obviously have a Bark() method that prints ‘Woof!'”. You don’t want to break all the Yorkie-dependent code just because Dog.Bark was added.
When you declare an abstract method on an abstract class, you’re telling the compiler, and developers who use your class that:
This method MUST be implemented by the subclass.
An abstract method cannot have a body. You’re telling the developer, I have a method you need to override, because only you know how to implement it. This is the signature, but the implementation is up to you.
The compiler will alert you if you subclass the abstract class without overriding the abstract method.
When you declare a virtual method on an abstract class, you’re telling the compiler, and developers who use your class that
This method CAN be overridden by the subclass.
The virtual method can be empty (unless it returns a value, whereby you MUST return something, or throw an exception), and it can have a default implementation, which subclasses will use if they do not override it.
You need to declare override to tell the compiler you are overriding the original implementation, otherwise you may create a New implementation, which I talked about here: https://www.reddit.com/r/csharp/comments/jzfimp/interview_question_new_keyoard_for_method/
which for some reason the question has been deleted.
I don’t understand all these questions that can be easily answered by just trying it out and seeing what the compiler allows.
You don’t really choose between them “when implementing abstract methods”. Here’s how it works.
Let’s think of a hierarchy:
In short:
If it’s the first time in an inheritance hierarchy a method is being defined, it MAY be virtual if you wish for other types to override it.
In an abstract class, it MAY be abstract if you don’t wish to provide implementation at this level.
If a method is defined in a base class, your only choice is to override it if you want new behavior.
If the method is not abstract or virtual in a base class, you cannot override it.
There is one other behavior using new instead of override, but it doesn’t behave the same way as these, is harder to explain, and solves a relatively rare and exotic problem so I don’t feel like expounding.
While it’s true Java doesn’t require this, some see it as a weakness, not a strength. In C#, we are being explicit that we INTEND to change our behavior. This is why some people like using the @Override annotation in Java. It helps people understand a method is being overridden on purpose rather than by accident.
Use override whenever you are overriding a virtual method inherited from a parent class.
Use virtual when you are declaring a method that is new to the current class, and you wish to provide a implementation in this class.
Use abstract when you are declaring a method that is new to the current class, you do not wish to provide an implementation in this class, and you want to require all inheritors of this class to provide their own implementation of the method. Note that this requires the current type also be declared abstract.
Use new on a method declaration on a method with the same signature (i. e. same name and arguments) as an inherited method, without overriding the original method. This is sometimes called ‘shadowing’, and has some implications for which version of a method will be called depending on the type of the reference to a value of your class. Try to avoid doing this: it’s confusing. Additionally: this keyword is optional, but the compiler with generate a warning if you omit it.
Use sealed on a method override to prevent child classes from overriding your implementation. They can still shadow it, though.
ETA: I accidentally a word in the override, new, and sealed explanations. Most of these apply only to virtual methods. new is the exception: you can shadow a method whether or not it’s virtual, and your new method can itself be virtual or not.
In Java, there is no need to do any of these.
In Java, all methods are virtual by default, and you cannot shadow a method on a parent class the way you can in C#. This was primarily a performance decision in C#, as there is a small performance penalty associated with virtual methods.
You should use override. You use virtual in a base class when you want to allow overriding of a specific method.
This drives the intention of the initial design.
C# devs
null reference exceptions

source