Hi..

Can you help me to understand clearly ,what is abstract class? And how i will used it, how it behaves in a class.


Thank you in advance!

Recommended Answers

All 3 Replies

1.Abstract class is a class which contains both abstract and concrete methods.
2.An Abstract class may or may not contain any abstract methods.
3.A class which will be declared as abstract then no need of that it must contain an abstract methods. But a class which contains an abstract methods then it must be declared as abstract class.
4.An abstract class cant be instantiated.
5.But we create a reference for an abstract class
6.suppose if we want to implement common methods for all subclass then we go for abstract class. other wise we go for interfaces.
7.We can't use both abstract and final at a time.

The other guys pretty much covered it
but in simple terms...
2 types of classes
Concrete class is the name used for the normal classes.
An abstract class can't be instantiated meaning abstract class is a class that you can't create objects from. It is useful for polymorphism and inheritance and stuff like that.
Abstract class is pretty much useless unless you extend it or its inherited.
Abstract methods are methods without a body(no curly brackets) just the header.
Abstract methods must be overridden .The point of having a abstract methods is for consistency and polymorphism. If a class uses abstract method the class must be declared as abstract.

if there is anything that you not sure with just ask

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.