java定义类、属性、方法(Java defines classes, attributes, methods).docVIP

  • 20
  • 0
  • 约1.02万字
  • 约 9页
  • 2017-08-31 发布于河南
  • 举报

java定义类、属性、方法(Java defines classes, attributes, methods).doc

java定义类、属性、方法(Java defines classes, attributes, methods)

java定义类、属性、方法(Java defines classes, attributes, methods) Java is an object oriented programming language, and the Java language provides the basic functions of defining classes, definitions, attributes, methods, and so on. Classes can be considered as a custom data type, and classes can be used to define variables. All variables that use class definitions are reference variables. They are referenced to the object of the class, which is created by the class. Class is used to describe the common features of a class of objects in the objective world, while objects are the concrete existence of classes, and Java programs use classes constructors to create objects of that class. Java also supports three object-oriented features: encapsulation, inheritance and polymorphism, Java, protected and public private provides three access control modifiers to achieve good encapsulation, provides the extends keyword to subclass inherits the parent class inherits class can be inherited to the properties and methods of the superclass, if access control allows the subclass instance can be defined by the method of direct call the parent class. Inheritance is an important means to implement class reuse. In addition, this kind of reuse can also be realized by combining relations. In a sense, inheritance and composition have the same function. Use inheritance to achieve reuse, a subclass object can be directly assigned to the parent class variables, this variable is polymorphic programming, more flexible, and to realize the reuse by using a combination of relations, do not have this flexibility. The constructor is used to initialize the operation of the class instance constructor support overloading, if multiple overloaded constructor contains the same initialization code, you can put the initialization code placed in ordinary initialization block, block total in the constructor is invoked before execution. In addition, Java provides a static initialization block, where the static initial

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档