10/17/2021 0 Comments Abstract Keyword In Java
We have created a class "WaterCan" declared as abstract and has methods named setDimensions as abstract and manfacPlace.So whoever is implementing, that class should have implementation for abstract methods.Package com.java.w3schools.core.abstracts Public abstract void setDimensions(double height, double diameter) Bisleri brand extends WaterCan. Whoever is extending this class, they have to provide implementation for the abstract methods.5) This does not have much importance unless it has sub classes.6) Abstract methods should be public or protected.7) Abstraction can be achieved either by declaring class as "abstract" or interfaces.8) If one method is abstract in any class, that class must declared as "abstract".9) If sub class does not provide implementation than that sub class must be declared as "abstract".10) If we do not know the implementation for a method that will be implemented by its sub class, than declare it as abstract.Example for abstract: We have mineral water suppliers. 2) Abstract class can have fields(properties), abstract methods.4) If we declare a method as abstract than no need to provide method body. In java program abstract class is deliberately missing. If a class have abstract methods, then the class should also be abstract using abstract keyword, else it will not compile.Abstract keyword will be used in method declaration to declare that method without providing the implementation in that java program. We can use abstract keyword to create an abstract method, an abstract method doesn’t have body.
![]() ![]() ![]()
0 Comments
Leave a Reply. |
AuthorSusan ArchivesCategories |