Forums Register Login

Abstract classes and Interfaces

+Pie Number of slices to send: Send
Can I get some answers please??

1) If an abstract class has more than one abstract method, when a subclass extends that class, does the sub class has to implement all the abstract methods? Can I extend an abstract class and not implement any abstract method?

2) If I implement an interface in my class, can I override a method in the interface? If I can, is there anyway I can get the original method implementation in my overriding class. Like the use of "super" in class methods to refer to the super class method?

Thanks.. :-)
+Pie Number of slices to send: Send
I can help you out on the first question and that is you have to implement all the abstract methods from the abstract class if you are in the first concrete class otherwise if you have an abstract class extending another abstract class then the first concret class must implement all the abstract methods.
+Pie Number of slices to send: Send
For the second question - if you implement an interface you must override the methods in the interface anyway.

Hope i've helped you in some way!
+Pie Number of slices to send: Send
So are all methods in Interfaces Abstract?
+Pie Number of slices to send: Send
All methods in an interface are implicitly public, abstract and non-static.
+Pie Number of slices to send: Send
Yep, all of the methods declared in an interface are implicitly public abstract, and therefor must ALL be implemented in the first concrete class.

I hired a bunch of ninjas. The fridge is empty, but I can't find them to tell them the mission.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 772 times.
Similar Threads
Regarding abstract class
overriding abstract method
Abstract & Interface
k&B SCJP 5 misleading in explaining inheriting interface impl. method
abstract classes
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 06:46:25.