#Java question

14 messages · Page 1 of 1 (latest)

rose dune
#

What is the difference between abstract and interface and why do you need it

humble cliffBOT
#

This post has been reserved for your question.

Hey @rose dune! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 720 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

minor spire
#

you can read more about it here

rose dune
prisma jay
#

It's also a relatively easy semantic question. Just ask yourself the following question, considering the classes extending/implementing the abstract class/interface: Is there a "is-a" relationship or are you trying to encapsulate/simplify/hide behinde/reduce to a functionality.
"is-a" => abstract class
reduction to a functionality => interface

ocean plume
#

Note: The abstract keyword is also used for methods which means "the body (code) of this method is provided by implementations/subclasses"

#

btw for questions like that: I highly recommend just trying it out and seeing what happens, that's how you really learn :)

rose dune