Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

abstract class without abstract methods

Posted on 2011-09-07
5
Medium Priority
?
330 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 2000 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 60

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

610 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