/    Sign up×
Community /Pin to ProfileBookmark

difference between abstract and concrete

Hey guys, got another question. Whats the difference between abstract and concrete classes and why are abstract classes used?

to post a comment
Java

1 Comments(s)

Copy linkTweet thisAlerts:
@buntineMar 22.2005 — Just a note, each answer you receive will differ slightly.

An abstract class should be created to represent an abstract concept, such as Shapes or Instruments.

For example, with instruments, you could set up an abstract class named Instrument. You would then sub-class it with a bunch of specific objects and conform to the layout of the super class (Instrument).

In the abstract class, you can make one or more methods abstract, which means they must be implemented in each subclass.
<i>
</i>public abstract class Instrument
{
public abstract void play();
}

public class Guitar extends Instrument
{
public void play()
{
}
}

An abstract class cannot be explicitely instantiated (via the [b]new[/b] keyword). Rather, it should be sub-classed.

Regards.
×

Success!

Help @brandongottier spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...