Abstraction
Abstraction
Another way, it shows only essential things to the user and hides the internal details, for
example, sending SMS where you type the text and send the message. You don't know the internal
processing about the message delivery.
Abstract class :
void disp() {
A method that doesn't have its body is known as an abstract method. We use the
same abstract keyword to create abstract methods. For example,
abstract void show();
Though abstract classes cannot be instantiated, we can create subclasses from it. We can
then access members of the abstract class using the object of the subclass. For example,
If the abstract class includes any abstract method, then all the child classes inherited from
the abstract superclass must provide the implementation of the abstract method. Otherwise get
an error. For example,
Example:
void show() {
}
}
public class abstraction {
public static void main(String[] args) {
useAsbtract a = new subA();
a.disp();
}
}
Output:
Interface: