Solved

abstract class without abstract methods

Posted on 2011-09-07
5
302 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping2 challenge 13 80
Eclipse Neon and jdk 1.8.0 11 126
for i loop in grovy 1 44
servlet example issue 6 29
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

929 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

13 Experts available now in Live!

Get 1:1 Help Now