Java abstract class/abstract method

Source: Internet
Author: User

Features of the Java abstract class:

* Abstract classes cannot be instantiated

* Subclass inherits Abstract class and instantiates subclass

* Subclasses inherit abstract classes has penny must implement abstract methods in abstract classes

* Definition of abstract class * * *

* Definition of abstract method: Public abstract void * * * (); PS: Abstract method cannot have method body

---------------------------------------------------------------------------

Let's take the following code implementation:

Create a. java file first

Then we define an abstract class

Abstract classes cannot be instantiated directly, we can let subclasses inherit and instantiate subclasses

Then we instantiate the subclass

Let's try it out:

--------------------------

PS: Subclass inherits abstract class must implement abstract method in abstract class, if we are abstract class inherit abstract words also can not inherit abstract method, obviously abstract subclass also cannot be instantiated.

Abstract class inheriting abstract class: abstract class Student extends person{

}

---------------------------------------------------------------------------------------------------------

Come on, Oh!!!

Java abstract class/abstract method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.