Java Fundamentals Review -7 (Private,this, inheritance)

Source: Internet
Author: User

1. What is the role of private in the encapsulation class?
A: The property and behavior in a class can be modified by private to make the modified property and behavior inaccessible.
General access to member properties: Assign (set), take a value (get get), so access to private variables can be by providing a corresponding setxxx or GetXXX method


2. What does the this keyword do in Java?
A: This represents the ontology of the class that is located, and if an external variable calls the class where this is located, this represents the external object. This is typically used to differentiate between member variables and local variables.
3. What is the concept and format of inheritance?
A: Subclasses inherit all the properties and methods of the parent class.
Format: Class Subclass extends parent class {}
4. What is the inheritance of a bit?
(1) Improve the reusable code, improve the efficiency of software development.
(2) The emergence of inheritance allows the relationship between classes and classes, providing a precondition for polymorphism.
What is the role of 5.super?
A: Super is used to represent a reference to the parent class object space contained in the current object.
6. What does rewriting mean? What precautions do you have?
A: When the method name of a method written in a subclass is the same as the method name of a method that inherits from the parent class, the new method overrides the old inherited method.
Note: (1) The subclass method overrides the parent class method and must ensure that the permission is greater than or equal to the parent class permission.
(2) Note: Must be exactly the same: The method's return value type method name parameter list will be the same.

Java Fundamentals Review -7 (Private,this, inheritance)

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.