14/04/2008
A class containing atleast one abstract method is called an abstract class. A method that has no implementation and which is expected to be implemented by a subclass is called an abstract method. An Abstract class cannot be instantiated. It is expected to be extended by a subclass. An abstract class may contain static variables declared. Any class with an abstract method must be declared explicitly as abstract. A class may be declared abstract even if it has no abstract methods. This prevents it from being instantiated.
Ads by Google











This site is very good and simple. I do have a question here. The first line says – “A class containing atleast one abstract method is called an abstract class” –
Isn’t it incorrect?
However in the last line you have mentioned clearly that abstract class may not have an abstract method.
regards,
prasanth
The abstract class may or may not have the abstract method. But if you have any abstract method then the class should be Abstract.
1. A class containing atleast one abstract method is called an abstract class.
2. A class may be declared abstract even if it has no abstract methods.
?????…
can abstract class have constructor ?
An abstract class is simple a class which cant be instantiated.
An abstract method defined within an abstract class must be implemented by all of its subclass.
Abstract method cannot be instantiated,it is generally used for inherited.
An abstract class may or may not have abstract methods.
public abstract class AAA
{
}
Bibhudutta Pradhan.
An abstract class may or may not have abstract methods.
public abstract class AAA
{
}
public abstract class AAA
{
// Nothing inside
}
This compiles absolutely fine.
Found a list of Abstract Class FAQ:
- Must abstract classes contain at least one abstract method?
- Can a static method be abstract?
- Why can’t an abstract method be declared private?
Q:How can I declare a constructor for an abstract class?
http://techguru.yakkoo.com/programming-concept-tutorials/2011/08/what-is-an-abstract-class-complete-reference/
Hi Joe,
Initially you said[first sentance of this topic], an abstract class should have atleast one abstract method. This is wrong know? It can have only instance methods as you mentioned at last.
Thanks,
Sharat
Can anyone please explain with an example?
HI All
Does Abastract class contains Constructor ?
abstract class contains default constructor,this constructor will be executed when ever we are creating an object of its sub class for initialization instance variables
y we cant instantiated the abstract class,please explain me detaillyy
y we cant instantiated the abstract class,please explain me detailly
because abstract class does not have full implementation of method. If we instantiate the abstract class, it would be incomplete instantiation. We can not use such type of instance because of incomplete method body. That’s why the technology restrict to us making a instance of Abstract class.
can a static method be abstract?
no
no, if we declare abstract method as static it shows compile time error. because if we declare abstract method as static it can’t be implemented.