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 : 33
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
Similar topics
» what are classes in java 2011 ?
» what is the concept of Wrapper Classes in java
» WHAT IS PDA in java
» What is difference b/w java Buzzwords and java Keywords?
» Java is to Write Once Run Anywhere thats what java language
» what is the concept of Wrapper Classes in java
» WHAT IS PDA in java
» What is difference b/w java Buzzwords and java Keywords?
» Java is to Write Once Run Anywhere thats what java language
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
Yesterday at 12:21 pm by ali001
» Hemangiom'App
Tue Nov 05, 2024 11:25 am by ali001
» MindfulMe - Mental Health App
Mon Nov 04, 2024 10:50 am by ali001
» Learn Candlestick Patterns
Tue Oct 15, 2024 5:51 am by ali001
» Woh Pagal Si Episode 52 to 62 - Top Pakistani Drama
Sat Sep 21, 2024 6:26 pm by Mir Emmad Ali Khan Domki
» Nearu - share your socials
Sat Sep 21, 2024 1:12 pm by ali001
» Nightclub Tycoon: Idle Empire
Thu Sep 19, 2024 9:16 pm by ali001
» Carnivore - Meat Diet Recipes
Wed Sep 18, 2024 2:37 pm by ali001
» Eid Milad un Nabi Mubarak 2024 (Rabiʻ I 14, 1446 AH)
Tue Sep 17, 2024 3:44 pm by Mir Emmad Ali Khan Domki