• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Abstract classes and Interfaces in Project

 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ??
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Base functionality.

Do you have access to Google or other search engine?!
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ??
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic