Solved

abstract class without abstract methods

Posted on 2011-09-07
5
304 Views
Last Modified: 2012-05-12
i would like to now about
abstract class without abstract methods

When, why, how, where we use it. I was under impression that abstract should have atleast 1 abstract method in it. I was not clear on this concept. thanks in advance
0
Comment
Question by:gudii9
  • 3
5 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 36495636

see here:
http://stackoverflow.com/questions/4811678/defining-an-abstract-class-without-any-abstract-methods

2 down vote accepted
      

Of course.

Declaring a class abstract only means that you don't allow it to be instantiated on its own.

Declaring a method abstract means that subclasses have to provide an implementation for that method.

The two are separate concepts, but obviously you can't have an abstract method in a non-abstract class.
link|improve this answer
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36495666


http://www.codestyle.org/java/faq-Abstract.shtml#whynoabstract
Q: Why do we need abstract classes with no abstract methods?

    A: An abstract class without any abstract methods should be a rare thing and you should always question your application design if this case arises. Normally you should refactor to use a concrete superclass in this scenario.

    One specific case where abstract class may justifiably have no abstract methods is where it partially implements an interface, with the intention that its subclasses must complete the interface. To take a slightly contrived motoring analogy, a Chassis class may partially implement a Vehicle interface and provide a set of core methods from which a range of concrete Vehicle types are extended. Chassis is not a viable implementation of a Vehicle in its own right, so a concrete Car subclass would have to implement interface methods for functional wheels, engine and bodywork.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36495682
SO when you declare such class you mean that those who woul use it can only extend it but cannot use it as it is.
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 36935272
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
eclipse java  build path 6 57
rhino JavaScript import, load 25 82
windows explorer path to command prompt 5 44
sql import cannot be resolved jsp 3 23
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question