What is abstract class | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is abstract class

24th Aug 2018, 1:51 PM
daredevil
daredevil - avatar
6 Answers
+ 3
Abstract class in java is similar to interface except that it can contain default method implementation. An abstract class can have abstract method without body and it can have methods with implementation also. abstract keyword is used to create a abstract class and method. Abstract class in java can’t be instantiated. Abstract class is mostly used to provide base for subclasses to extend and implement the abstract methods and override or use the implemented methods in abstract class.
24th Aug 2018, 5:24 PM
Maninder $ingh
Maninder $ingh - avatar
24th Aug 2018, 5:28 PM
Maninder $ingh
Maninder $ingh - avatar
+ 2
An abstract class is a class that is declared abstract —it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed. When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class. You can't make an object of an abstract class and if a class is extended from an abstract class, you need to implement all of the methods which where declared in the abstract class
24th Aug 2018, 2:59 PM
MarJan
MarJan - avatar
+ 2
Maninder Singh how is abstraction achieved using abstract class?? can you show an example
24th Aug 2018, 5:26 PM
Keerttik Titan
Keerttik Titan - avatar
+ 1
An abstract(empty) class may have abstract(with no body) or non-abstract methods. Abstraction in class makes it work like an interface.The sub-class must implement all abstract methods or else it must be declaired as an abstract class also.
24th Aug 2018, 3:21 PM
Stratos Varvatakis
Stratos Varvatakis - avatar
0
any example for abstract class
5th Sep 2018, 9:46 AM
daredevil
daredevil - avatar