In Java, an abstract class is a class definition where we don't provide all the implementation details. The class has the keyword "abstract" added to it here. We denote abstract classes in our diagrams by making the class name in italics.
We can also mark some of the methods as abstract. That means we just provide the method signature and return type, but we don't provide the Java block that implements the method. We mark the methods with the keyword "abstract". Note the method has no braces, no implementation, and just ends with a semi-colon. Again we use italics for abstract methods in our diagrams.
If we declare a class as abstract, the methods may or may not be abstract. We don't need to have any abstract methods. It would be weird, because what would be the point, but we can do it. The opposite isn't true. If we mark any method as abstract, we must mark the class as abstract.
Another note. We can’t have a method that is abstract and private. We couldn’t access it, and there’s really no point. If you’re protecting it for subclasses, you’ll want to use protected.
#java #programming #tutorial
▼
Like the video? Don't forget to subscribe! ➜ www.deegeu.com/...
▼
Keep up to date with the newsletter! ➜ www.deegeu.com/...
Transcript and code: : www.deegeu.com/...
Concepts: Java, classes, abstract classes, Compile-time safety
Social Links: Don't hesitate to contact me if you have any further questions.
WEBSITE : dj@deegeu.com
TWITTER : / deege
FACEBOOK: / deegeu.programming.tut...
GOOGLE+ : google.com/+Dee...
Hosted by DJ Spiess
About Me: www.deegeu.com/...
Related Videos:
What are static factory methods in Java? - 036
• What are static factor...
Free Java Course Online
• What important Java Te...
Media credits: All images are owned by DJ Spiess unless listed below:
Cookies
videos.pexels.com under CC0
Music
Easy Jam by Kevin MacLeod is licensed under a Creative Commons Attribution license (creativecommon...)
Source: incompetech.com...
Artist: incompetech.com/
14 окт 2024