Several Basic concepts of Java

Source: Internet
Author: User

Java Basic Concepts

Abstract class: specifies that the category of one or more abstract methods must be defined as abstract. abstract classes are only used to derive subclasses, but cannot be used to create objects.

Final class: Also known as "final class", it can only be used to create objects, but cannot be inherited. It is the opposite of an abstract class, and the abstract class and the final class cannot be simultaneously modified with the same class.

Package: a Java package is a collection of related classes and interfaces. The keyword package must be used to create a package.

Polymorphism: in java, object variables are polymorphism. Java does not support multiple inheritance.

Interface: interfaces in Java are a series of methods declarations, which are a collection of Methods features. An interface has only the features of methods and has no methods to implement, therefore, these methods can be implemented by different classes in different places, and these implementations can have different behaviors (functions ).

Every class in Java is extended from the Object class.

The equal and toString methods in the object class.

Equal is used to test whether an object is equal to another object.

ToString returns a string representing the Object. Each class inherits the method from the Object class. Some Classes overwrite the method to return the correct expression of the current state.

(The toString method is a very important method)

General programming: all values of any class type can be replaced by variables of the object type.

Encapsulation: combines data and behavior in a package and hides data from the object user. The data in an object is called its instance field ).

Overload: when multiple methods have the same name and contain different parameters, the overload occurs. The compiler must select the method to call for compilation.

Rewrite: overwrite the method ." In Java, subclasses can inherit the methods in the parent class without re-writing the same method. But sometimes the subclass does not want to inherit the parent class from the original method, but wants to make some modifications, which requires method rewriting. It is worth noting that when the subclass redefines existing methods of the parent class, it should maintain the same method header declaration as that of the parent class.

ArrayList: ArrayListDynamic ArrayList, which is a class library defined in the java. util package. The array size can be adjusted automatically.

The getclass method in the class object class returns an instance of the class type. When the program starts, the class contained in the main method will be loaded, and the VM will load all the classes required by the program, each loaded class must load the class it needs. [2]

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.