4.50 member characteristics of abstract classes

Source: Internet
Author: User

/* Member characteristics of abstract class: member variable: can be either a variable or a constant. Construction method: there is. Initializes the child class to access the parent class data. Member methods: can be either abstract or non-abstract. Member method attributes for abstract classes: A: Abstract methods enforce what subclasses do. B: The non-abstract method subclass inherits things, improves the code reusability. */abstract class Animal {public int num = 10;public final int num2 = 20;public Animal () {}public Animal (String name, int a GE) {}public abstract void Show ();p ublic void Method () {System.out.println ("method");}} Class Dog extends Animal {public void Show () {System.out.println ("show Dog");}} Class AbstractDemo2 {public static void main (string[] args) {//create object animal a = new Dog (); a.num = 100; System.out.println (a.num);//a.num2 = 200; System.out.println (A.NUM2); System.out.println ("--------------"); A.show (); A.method ();}}


4.50 member characteristics of abstract classes

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.