SCJP 6, SCWCD 5, SCBCD 5
SCJP 1.6 in progress ....
Dejan Miler wrote:We use abstract class when we want to force implementing class to implement abstract class methods.
OCJP 6 (93%)
SCJP 1.6 in progress ....
Lorand Komaromi wrote:
Dejan Miler wrote:We use abstract class when we want to force implementing class to implement abstract class methods.
Wrong, an abstract class doesn't need to have any abstract methods...
SCJP 6, SCWCD 5, SCBCD 5
To err is human,
To forgive is not company policy
Yes , Dejan Miler statement is not for abstract class, it is actually more appropriate for interface, all method in interface is implicitly public abstract.
SCJP 1.6 in progress ....
we declare a class abstract for two reasons
1)to prevent creting objects
2)if the class has any abstract methods
if the class has abstract methods then the class that inherits it must implemet the methods that are declared abstract or declare itself abstract....
Hence if you want to force a sub class to implement the super class method the method must be declared abstract and the class abstract
SCJP 6, SCWCD 5, SCBCD 5
I agree that statment is more appropriate for interface.
But we all know that we can have abstract class with methods who are all abstract.
So if all methods in abstract classes are abstract we can say that that class is very similar to interface.
And we all know that interface is 100% abstract and class can or do not need to be 100% abstract.
SCJP 6, SCWCD 5, SCBCD 5
SCJP 1.6 in progress ....
SCJP 1.6 in progress ....
But one more doubt, suppose if i will add two more concrete methods(like m4() and m5())to my abstract class,will it break the clients code(who uses my code)?
SCJP 6, SCWCD 5, SCBCD 5
Consider Paul's rocket mass heater. |