Doubt regarding abstract class
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi All,
I have small doubt regarding Abstract class.
"If a class has single abstract method, than class must be declared as an abstract class."
But Does it necessary that abstract class must have a single abstract method? It abstact class does not have single abstract method then there is no meaning of creating that class as an abstract class. It is useless to create a class as an abstract without having any abstract method in it.
I tried to find answer to my above doubt but its not clearly mentioned in the book or site.
Could anyone please help me clarifying my above doubt?
Thanks in Advance.
I have small doubt regarding Abstract class.
"If a class has single abstract method, than class must be declared as an abstract class."
But Does it necessary that abstract class must have a single abstract method? It abstact class does not have single abstract method then there is no meaning of creating that class as an abstract class. It is useless to create a class as an abstract without having any abstract method in it.
I tried to find answer to my above doubt but its not clearly mentioned in the book or site.
Could anyone please help me clarifying my above doubt?
Thanks in Advance.
posted 14 years ago
Your logic is perfect. No, that statement does not imply that an abstract class must have an abstract method. And in fact it is possible to create an abstract class which has no abstract methods. (Of course you could have tried that yourself.)
On the other hand there are competent programmers who have done exactly that. So your opinion differs from theirs.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Jay Shukla wrote:"If a class has single abstract method, than class must be declared as an abstract class."
But Does it necessary that abstract class must have a single abstract method?
Your logic is perfect. No, that statement does not imply that an abstract class must have an abstract method. And in fact it is possible to create an abstract class which has no abstract methods. (Of course you could have tried that yourself.)
It abstact class does not have single abstract method then there is no meaning of creating that class as an abstract class. It is useless to create a class as an abstract without having any abstract method in it.
On the other hand there are competent programmers who have done exactly that. So your opinion differs from theirs.
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi,
Actually Abstract means it impose the class which is extending the abstract class to implement the abstract methods in it.So if you dont have any abstract methods in it there is a possibility to have abstract methods in it
in the future.
The base line is whenever you impose some class to have the body of the abstract methods then only we go for abstract class.
Thanks
Rajkiran
Actually Abstract means it impose the class which is extending the abstract class to implement the abstract methods in it.So if you dont have any abstract methods in it there is a possibility to have abstract methods in it
in the future.
The base line is whenever you impose some class to have the body of the abstract methods then only we go for abstract class.
Thanks
Rajkiran
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
rajkiran vadla, welcome to the Ranch 

posted 14 years ago
Ah, but you forgot one other very important point about an abstract class: it cannot be instantiated (ie, you cannot call 'new' on it); therefore, it you have a class that you don't want to be instantiated directly, you could make it abstract.
Winston
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Jay Shukla wrote:It abstact class does not have single abstract method then there is no meaning of creating that class as an abstract class.
Ah, but you forgot one other very important point about an abstract class: it cannot be instantiated (ie, you cannot call 'new' on it); therefore, it you have a class that you don't want to be instantiated directly, you could make it abstract.
Winston
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
| There's a way to do it better - find it. -Edison. A better tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |











