wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Can we mark an overriding method as abstract Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Can we mark an overriding method as abstract" Watch "Can we mark an overriding method as abstract" New topic
Author

Can we mark an overriding method as abstract

Simran Dass
Ranch Hand

Joined: Jan 09, 2010
Posts: 183

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
Sheriff

Joined: Sep 28, 2004
Posts: 18876
    
  40

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

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Simran Dass
Ranch Hand

Joined: Jan 09, 2010
Posts: 183

Yeah. Thanks for the quick reply.
Prithvi Sehgal
Ranch Hand

Joined: Oct 13, 2009
Posts: 774
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,


Prithvi,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

This code if fine, but useless and I think that it violates the LSP principle a little, but it depends on the interpretation.


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
 
wood burning stoves
 
subject: Can we mark an overriding method as abstract