Ravi Kiran Va
,
Ranch Hand
Dec 20, 2009 10:47:04
Hi
This is a interview question .
Please tell me whether it is good to use Interfaces or abstract classes in a project ??
Actually i don't see any usefulness in using a Abstarct class
rohan yadav
,
Ranch Hand
Dec 20, 2009 11:17:50
Hi Ravi, I think its good to use Interfaces and Abstract classes in your program, as it will increase encapsulation and promote code reusability.
Ravi Kiran Va
,
Ranch Hand
Dec 20, 2009 12:01:33
Ya i know we need to use Interfaces as Data Access Layer , but still cant get where Abstract classes will be useful actually . any scenario ??
David Newton
,
Author
Dec 20, 2009 12:07:50
Base functionality.
Do you have access to Google or other search engine?!
Henry Wong
,
author
staff
Dec 20, 2009 12:08:56
Ravi Kiran V wrote:
This is a interview question .
Actually i don't see any usefulness in using a Abstarct class
Hopefully, you didn't answer this as such during the interview !
Henry
Hiram Nascimento
,
Greenhorn
Dec 20, 2009 18:45:13
Hi Ravi,
The key usefulness of Interfaces and Abstract classes is Polymorphism .
Also, once Java doesn't support multiple inheritance, Interfaces resolves the "Diamond of Death" problem if you know how to use them.
They also provide advantages for your application's design.
Did I convince you?
regards,
Hiram
Ravi Kiran Va
,
Ranch Hand
Dec 21, 2009 01:10:25
Did I convince you?
some what
The question is not about my class extending multiple classes at same time .
But i use interface to define a contact but when to go with Abstrat class actually ??
Campbell Ritchie
,
Marshal
staff
Dec 21, 2009 03:53:17
Ravi Kiran V wrote: But i use interface to define a contact but when to go with Abstrat class actually ??
Google is your friend
Hiram Nascimento
,
Greenhorn
Dec 21, 2009 09:49:41
An interface is a fully abstract class that only defines a contract and has no implementation.
All interface methods are implicitly public abstract.
The abstract classes accept you to define a contract but also allow you to implement some methods (which are concrete).
So, if you have a fully abstract class you have an Interface, if you have a partial abstract class you can have an Abstract Class, but if you have fully concrete class you have a normal Class.
Hiram
Shiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com