Solved

abstract class without abstract methods

Posted on 2011-09-07
5
301 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
Comment Utility

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
Comment Utility


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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now