Please enable JavaScript.
Coggle requires JavaScript to display documents.
Creating abstract classes (Abstract class (can has abstract methods…
Creating abstract classes
Abstract class
has keyword abstract
e.g public abstract class Animal{}
There is no implementation
can has abstract methods
public abstract String getName();
only be create in abstract class
cannot have an implementation
e.g. public abstract void swim(){}//Does not compile
cannot be final
public abstract final void chew();//Does not compile
cannot be private
private abstract void sing();//Does not compile
cannot instantiation it
Can have methods and variables nonabstract
cannot be final
e.g. public final abstract class Tortoise{} //Does not compile
Creating a Concrete Class
extends a abstract class
makes sense
implement all abstract methods
tip for exam
because will not compile
Extending an Abstract Class
Abstract class definition rules
1 - Cannot instatiated
2 - zero or more abstract methods or nonabstract
3 - Cannot be private or final
4 - Class abstract extend another inherits all of its abstract methods
5 - The first concrete class must provide implementation to abstract methods.
Abstract method definition rules
3 - Must not provide a implementation/body
4 - Implementing an abstract method in a subclass follow the same rules for overriding methods.
2 - Cannot be private or final
1 - Only defined in abstract classes