Abstract classes vs. Interfaces in java

View previous topic View next topic Go down

GMT - 3 Hours Abstract classes vs. Interfaces in java

Post by Diya on Sun May 29, 2011 4:22 pm

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.
Diya
Diya
Monstars
Monstars

Taurus Goat
Posts : 364
Join date : 2011-02-08
Age : 28
--Mood-- : Notworthy

Character sheet
Experience:
Abstract classes vs. Interfaces in java Left_bar_bleue10/500Abstract classes vs. Interfaces in java Empty_bar_bleue  (10/500)

Back to top Go down

GMT - 3 Hours Re: Abstract classes vs. Interfaces in java

Post by Vuhelper on Sun May 29, 2011 4:24 pm

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.
avatar
Vuhelper
Deep Bench
Deep Bench

Posts : 97
Join date : 2011-05-29

Back to top Go down

GMT - 3 Hours Re: Abstract classes vs. Interfaces in java

Post by plhr60 on Sat Apr 20, 2013 3:15 pm

Sounds like a sweet deal, thanks virtualposition! Thumbs up Thumbs up Thumbs up
plhr60
plhr60
Monstars
Monstars

Aquarius Horse
Posts : 536
Join date : 2011-10-20
Age : 29
--Mood-- : Drunk

Character sheet
Experience:
Abstract classes vs. Interfaces in java Left_bar_bleue33/500Abstract classes vs. Interfaces in java Empty_bar_bleue  (33/500)

Back to top Go down

GMT - 3 Hours Re: Abstract classes vs. Interfaces in java

Post by ChIntoo on Sat Apr 20, 2013 3:17 pm

I have just one word to describe this: AMAZING!!! Thank you virtualposition [You must be registered and logged in to see this image.] [You must be registered and logged in to see this image.] [You must be registered and logged in to see this image.]
ChIntoo
ChIntoo
Monstars
Monstars

Posts : 92
Join date : 2011-02-13

Back to top Go down

GMT - 3 Hours Re: Abstract classes vs. Interfaces in java

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


Permissions in this forum:
You cannot reply to topics in this forum