Abstract classes vs. Interfaces in java
Virtual Position Forum :: Members Lounge :: Sciences & Knowledge :: Programing and Design :: Java Forum
Page 1 of 1 • Share
Abstract classes vs. Interfaces in java
Following queries which creating problems to understand, which are
1- give the brief detail theory about both the techniques.i.e. Abstract classes vs. Interfaces
2- often you call the functions with the help of class name without using the object of the specific class, according to my concept of c++ we can only do this only when class declared as a static, i want to know that is it any concept in Java to manipulate the function in this style.
1- give the brief detail theory about both the techniques.i.e. Abstract classes vs. Interfaces
2- often you call the functions with the help of class name without using the object of the specific class, according to my concept of c++ we can only do this only when class declared as a static, i want to know that is it any concept in Java to manipulate the function in this style.
Diya- Monstars
-
Posts : 364
Join date : 2011-02-08
Age : 32
Character sheet
Experience:
(10/500)
Re: Abstract classes vs. Interfaces in java
We can not make instance of Abstract Class as well as Interface.
Here are few differences in Abstract class and Interface as per the definition.
Abstract class can contain abstract methods, abstract property as well as other members (just like normal class).
Interface can only contain abstract methods, properties but we don’t need to put abstract and public keyword. All the methods and properties defined in Interface are by default public and abstract.
When To Use Interfaces
An interface allows somebody to start from scratch to implement your interface or implement your interface in some other code whose original or primary purpose was quite different from your interface. To them, your interface is only incidental, something that have to add on to the their code to be able to use your package.
When To Use Abstract classes
An abstract class, in contrast, provides more structure. It usually defines some default implementations and provides some tools useful for a full implementation. The catch is, code using it must use your class as the base. That may be highly inconvenient if the other programmers wanting to use your package have already developed their own class hierarchy independently. In Java, a class can inherit from only one base class.
Here are few differences in Abstract class and Interface as per the definition.
Abstract class can contain abstract methods, abstract property as well as other members (just like normal class).
Interface can only contain abstract methods, properties but we don’t need to put abstract and public keyword. All the methods and properties defined in Interface are by default public and abstract.
When To Use Interfaces
An interface allows somebody to start from scratch to implement your interface or implement your interface in some other code whose original or primary purpose was quite different from your interface. To them, your interface is only incidental, something that have to add on to the their code to be able to use your package.
When To Use Abstract classes
An abstract class, in contrast, provides more structure. It usually defines some default implementations and provides some tools useful for a full implementation. The catch is, code using it must use your class as the base. That may be highly inconvenient if the other programmers wanting to use your package have already developed their own class hierarchy independently. In Java, a class can inherit from only one base class.
Vuhelper- Deep Bench
- Posts : 97
Join date : 2011-05-29
Re: Abstract classes vs. Interfaces in java
Sounds like a sweet deal, thanks virtualposition!
plhr60- Monstars
-
Posts : 536
Join date : 2011-10-20
Age : 34
Character sheet
Experience:
(33/500)
Re: Abstract classes vs. Interfaces in java
I have just one word to describe this: AMAZING!!! Thank you virtualposition [You must be registered and logged in to see this image.]
ChIntoo- Monstars
- Posts : 92
Join date : 2011-02-13
Virtual Position Forum :: Members Lounge :: Sciences & Knowledge :: Programing and Design :: Java Forum
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Sat Mar 23, 2024 1:08 pm by ali001
» MindCat: Mindfulness, Meditate
Tue Mar 19, 2024 7:35 am by ali001
» Jordan 1 1 ST Firstcopy Shoes
Sat Mar 09, 2024 6:08 pm by ali001
» Frienzy: Travel with Friends
Fri Mar 08, 2024 7:18 pm by ali001
» Frienzy: Travel with Friends
Fri Mar 08, 2024 7:02 pm by ali001
» DUO Decisions: Choose at random
Fri Mar 08, 2024 11:29 am by ali001
» Yodel Community Connections
Wed Feb 28, 2024 12:56 pm by ali001
» Yodel Community Connections
Wed Feb 28, 2024 12:55 pm by ali001
» Live Timeless - Habit Tracker App
Sat Feb 10, 2024 8:33 pm by ali001