Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we mark an overriding method as abstract

 
Simran Dass
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can we mark an overriding method as abstract ?


Cannot understand how the code in class B works. Why would we want to do this
 
Henry Wong
author
Marshal
Pie
Posts: 21412
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simran Dass wrote:
Cannot understand how the code in class B works. Why would we want to do this


Basically, you want to create a new class that IS-A a particular sub class, but you don't have the complete implementation. Or you have multiple possible implementations, of which the subclass implementation is not one of them.

Granted, it is not a common case, but it can happen.

Henry
 
Simran Dass
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Yeah. Thanks for the quick reply.
 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In what cases, such a scenario can happen? I find this quiet meaningless. Umm that too marking an instance method as abstract.
Doesn't it violate the rules of overriding?

Best Regards,
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code if fine, but useless and I think that it violates the LSP principle a little, but it depends on the interpretation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic