201671010114 2016-2017-2 "Java Programming" Fifth Week study summary

Source: Internet
Author: User

This week, I learned a lot about inheritance, and I know more about it than I did last week. During this writing process, it is found that the prompt statement inside the For loop will appear two times at run time, and the program will make an error. i++ in the loop when the program runs normally, if you put in the For statement inside the program error. Hesheyu after trying to obtain the above results, but do not know the principle inside.

Subclasses inherit all the methods of the parent class, and new methods are added to the subclass, and each subclass can have at most one parent class, and the parent class cannot access the methods in the child class. A variable defined with a subclass can be assigned to a variable that is defined with the parent class, and vice versa. You can define a constant by final, and the object must be assigned a value. A variable defined by private can only be used in the same class, a variable or method defined by public can be used by all classes, and variables defined by protected can be used in the same package. Casts allow you to convert the type of the parent class to the type of the child class. In the parent class, if the abstract method is defined, the parent class must also be decorated with an abstract, and if the child class defines all the abstract methods in the parent class, the subclass may not be an abstract class. Conversely, subclasses are abstract classes. An abstract class can contain specific data and methods, or it can contain no abstract methods. By using a method name in a super.+ parent class in a subclass, you can call the value in the parent class by using the Super override method. A generic array can be defined by ArrayList, regardless of the size of the array. The contents of this chapter will be digested again.

201671010114 2016-2017-2 "Java Programming" Fifth Week study summary

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.