When to use an abstract class in Java – 038

Review



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.

Quý khách hãy đăng ký để nhận Khuyến Mãi bên dưới của nhà cái Fi88

 

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! ➜


Keep up to date with the newsletter! ➜

Transcript and code: :

Concepts: Java, classes, abstract classes, Compile-time safety

Social Links: Don’t hesitate to contact me if you have any further questions.
WEBSITE : [email protected]
TWITTER :
FACEBOOK:
GOOGLE+ :

Hosted by DJ Spiess
About Me:

Related Videos:

What are static factory methods in Java? – 036

Free Java Course Online

Media credits: All images are owned by DJ Spiess unless listed below:

Cookies
under CC0

Quý khách hãy đăng ký để nhận Khuyến Mãi bên dưới của nhà cái Fi88

 

Music
Easy Jam by Kevin MacLeod is licensed under a Creative Commons Attribution license (
Source:
Artist:

Tag: abstract class vs interface java, tutorial, programming, deegeu, www.deegeu.com, dj spiess, abstract classes, abstract class in Java, Java (Programming Language), Abstract Type, Programming Language (Software Genre), abstract class, java programming, java programming – step by step tutorial, java programming for beginners, java programming tutorial for beginners, java tutorial, java programming tutorial

Xem thêm: https://mọtgame365.vn/category/review

Nguồn: https://mọtgame365.vn

You May Also Like

OMG 3Q S407 . Tặng acc có trang bị Liệt Thiên Giáp free dành cho AE tâm huyết
Java – Bài 55: So sánh giữa abtract class và interface
Tuyendaily22

Must Read

Không tìm thấy kết quả.
Menu