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
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?
» what is difference b/w Java and Java Script?
» what is the concept of Wrapper Classes in java
» WHAT IS PDA in java
» What is difference b/w java Buzzwords and java Keywords?
» what is difference b/w Java and Java Script?
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 May 04, 2024 11:49 am by ali001
» house disrepair claims
Thu May 02, 2024 4:29 pm by Ibad Khan Buledi
» Bounce n Bang: Physics puzzler
Thu May 02, 2024 11:39 am by ali001
» AIChatSY - AIChatbot Assistant
Wed May 01, 2024 10:48 am by ali001
» Storybook Magic App
Tue Apr 30, 2024 7:06 pm by ali001
» Flower Book Match3 Puzzle Game
Tue Apr 30, 2024 12:17 pm by ali001
» Avian Influenza Symptom in Chickens "Bird Flu H5N1 Virus" Vet learning materials, Poultry Farming
Sat Apr 27, 2024 9:57 am by Ibad Khan Buledi
» Aloha Planner - Note-Taker
Thu Apr 11, 2024 4:52 pm by ali001
» Streaming Guide Film TV Series
Tue Apr 09, 2024 9:39 pm by ali001