Abstract Classes in Java In C++, if a class has at least one pure virtual function, then the class becomes abstract. Unlike C++, in Java, a separate keyword abstract is used to make a class abstract. // An example abstract class in Java abstract class Shape { int color; // An abstract function (like a pure virtual function in C++) abstract void draw(); } Following are some important observations about abstract classes in Java. 1) Like C++, in Java, an instance of an abstract class cannot be created, we can have references of abstract class type though.
Read full article from Abstract Classes in Java | GeeksforGeeks
No comments:
Post a Comment