• Post Reply Bookmark Topic Watch Topic
  • New Topic

Abstract and Concrete class  RSS feed

 
S Thanigaivel
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does abstract class and concrete class mean?

plz give a small implementation scenario in which case these both would be used. Also purpose of them

Thanks in Advance
 
John Dell'Oso
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This topic has been discussed many times before on these forums. Try the search function and see what results you get. If you're not happy with the results found on these forums, have a Google.

Regards,
JD
 
Aum Tao
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abstract class is one in which the method is not defined, only declared and hence is incomplete. Therefore, we cannot create an instance. However, these methods need to be defined in the derived classes, or else they also become abstract. Interfaces are examples of abstract class.
A class which does not contain any undefined method is a concrete class.

We make a class abstract when it is too general and so it makes no sense to make an object of this class. Consider, the shaper class having methods calArea() undefined. Now, this abstract class or interface can be implemented by concrete classes like Circle, Square, etc to define their own calArea() method, as needed.

P.S. - I think, you should refer some textbooks for such fundamental topics or search google.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this abstract classes and methods section from the Polymorphism chapter of Bruce Eckel's Thinking in Java.
 
shanti jarnala
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abstract class can contain both abstract and concrete methods. Abstract method is the one which has no definition but will be just declared.
Abstract class cannot be instantiated.

abstract class AbstractTest//contains abstract method which is to be //implemented or defined in sub classes.
{
void one()
{//definition of method.
}
abstract void two();//we just declare abstract method.
}


Concrete class is the one which is not an abstract class.
class ConcreteTest extends AbstractTest
{
void two()
{//providing implementation or definition
}

}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!