01JavaSE [Encapsulation, inheritance, abstraction]

java const string int get static main Pictures Upload Write your review! Come on, watch it all Member login | User registration Recommended reading (adsbygoogle = window.adsbygoogle || []).push({}); <!– –> .syntaxhighlighter{ width: 740px; padding-top:40px;padding-bottom:20px; border: 1px solid #333; background: url(“/style/SyntaxHighlighter/top_bg.svg”); background-size: 43px; background-repeat: no-repeat; margin-bottom: -7px; border-radius: 15px; background-position: 16px 12px; padding-left: 10px; } .gutter{ display: none; }

java turns 3 into 03_Java basics summarizes its own weak links 03 (object-oriented encapsulation, inheritance)

1. Let’s talk about object-oriented thinking 1. What is object-oriented 1) Object-oriented is based on objects – “complete various operations” xff0c; emphasizes the object and the result. 2) Process-oriented is based on functions and “completes various operations” emphasizing the process. 3) Object-oriented is based on process-oriented. 2. Characteristics of object-oriented thinking 1) An idea that is more in line with people’s thinking habits 2) Simplifying complex problems 3) We have changed from executors to commanders Example : Buying a computer yourself vs asking friends to help buy a computer (Process-oriented) (Object-oriented) ) 2. Classes and Objects 1. A class is a collection of related attributes and behaviors , is an abstract concept 2. An object is a certain The specific existence of a thing is a specific form of representation Example: student (category) Xiao Ming (object) 3. The difference between member variables and local variables 1. Definition location Member variables : outside methods in the class Local variables : in the class Formal parameters within a method or on a method 2. Initialization differences Member variables have default initialization values Local variables #xff1a;None 3. Storage location: Member variables:Exist with the existence of the object in the heap Local variables& #xff1a;…

JAVA object-oriented encapsulation, inheritance, polymorphism, abstraction (detailed understanding)

Creating an object of a class = instantiating the class = instantiating the class The use of classes and objects (implementation of object-oriented ideas): 1. Create a class and design the members of the class 2. Create an object of the class 3. Call the structure of the object through “object.property” or “object.method” If multiple objects of a class are created, each object has an independent set of properties of the class. (non-static) It means that if we modify the attribute a of one object, it will not affect the value of attribute a of another object. The whole process of instantiation of subclass objects 1. Judging from the results: (inheritance) After the subclass inherits the parent class, it obtains the attributes and methods declared in the parent class. Create an object of the subclass, and in the pair space, all properties declared in the parent class will be loaded. 2. From a process perspective: When we create a subclass object through the subclass’s constructor, we will definitely call the constructor of its parent class directly or indirectly, and then call the constructor of the parent class’s parent class. Until the constructor with empty parameters in the java.lang.Object class is…

c37e0e874d3cea38416ed642d7364065.png

Java inheritance, polymorphism, and encapsulation. Javascript is based on the three major characteristics of objects (encapsulation, inheritance, and polymorphism)…

The three major object-based characteristics of Javascript are the same as the three major object-oriented characteristics of C++ and Java. They are encapsulation, inheritance and polymorphism. polymorphism). It’s just that the implementation methods are different – the basic concepts are almost the same. In fact, in addition to the three major characteristics, there is another common characteristic called abstract. This is why we sometimes see the four major characteristics of object-oriented in some books. 1. Encapsulation: Encapsulation is to encapsulate abstracted data and operations on the data. The data is protected internally. Other parts of the program can only be accessed through authorized operations ( Member method), can operate on data. Case: function Person(name, agei, sal){ // public this.name & #61; name; // private var age = agei; var salary = sal; } var p1 = new Person('zs', 20, 10000); window.alert(p1.name &#43 ; p1.age); PS:JS encapsulation has only two states,one is public,one is private. The difference between adding member methods through the constructor and adding member methods through the prototype method 1. Functions allocated through the prototype method are shared by all objects. 2. Attributes assigned through the prototype method are independent. (If you do not modify the attributes, they…

Object instances in java packaging, Java study notes (4) – Understanding classes, objects, encapsulation, inheritance, polymorphism, packagers…

1. Basic object-oriented concepts – class, object, encapsulation, inheritance, polymorphism, packager (1) Encapsulation – is the combination of data and behavior A unified whole,and hides the data implementation process from object users. (2) Inheritance:Java inheritance is a technology that uses the definition of an existing class as a basis to create a new class,Inheritance avoids the need for common features between general classes and special classes. of repeated descriptions. Polymorphism:Polymorphism refers to the same entity having multiple forms at the same time. The relationship between classes and objects:A class is a basic prototype that describes a type of things with the same characteristics,It defines the data characteristics that such things have and the operations that can be performed&#xff1b ;The object is an instance of the class,It is the concretization of the class The Java class is the basic embodiment of the concept of object-oriented encapsulation,The Java class encapsulates the data (properties) and behavior of the abstract concept ( method). The basic composition of java classes:Attributes, methods, construction methods Attributes are the description of the data characteristics of abstract concepts by the class,Methods are the behavior of the class on the concept Description of the constructor initializes a class object when…

(10) CoreJava object-oriented (encapsulation, inheritance, polymorphism, interface) 01 (95)

java static main Security get string jvm Array text Write your review! Come on, watch it all Member login | User registration Recommended reading (adsbygoogle = window.adsbygoogle || []).push({}); <!– –> .syntaxhighlighter{ width: 740px; padding-top:40px;padding-bottom:20px; border: 1px solid #333; background: url(“/style/SyntaxHighlighter/top_bg.svg”); background-size: 43px; background-repeat: no-repeat; margin-bottom: -7px; border-radius: 15px; background-position: 16px 12px; padding-left: 10px; } .gutter{ display: none; }

How to clearly explain Java object-oriented issues and knowledge? (Classes and objects, encapsulation, inheritance, polymorphism, interfaces, inner classes…)

java Pictures ide int view git https Editor WeChat Write your review! Come on, watch it all Member login | User registration Recommended reading (adsbygoogle = window.adsbygoogle || []).push({}); <!– –> .syntaxhighlighter{ width: 740px; padding-top:40px;padding-bottom:20px; border: 1px solid #333; background: url(“/style/SyntaxHighlighter/top_bg.svg”); background-size: 43px; background-repeat: no-repeat; margin-bottom: -7px; border-radius: 15px; background-position: 16px 12px; padding-left: 10px; } .gutter{ display: none; }

Java abstract classes, inheritance, polymorphism and adapter implementation code

Implementation code of Java abstract classes, inheritance, polymorphism and adapters

Java inheritance Method rewriting is a polymorphic feature of the Java language and must meet the following conditions In the subclass, the method name is exactly the same as the parent class method name The number and type of parameters of the method are exactly the same, and the return type is exactly the same The access modifier access level of the method is not lower than the access level of the method with the same name in the parent class Add the @override annotation on the method. If an error is reported, it means it is not an override Method overriding restrictions The parent class method modified by final cannot be overridden in the subclass Static-modified parent class methods cannot be overridden in subclasses, but can only be overridden super keyword The super keyword is similar to this. super modifies the object of the parent class, such as super(); it calls the default parameterless constructor of the parent class Java abstract class Abstract class characteristics Abstract classes should usually contain abstract methods and can also contain non-abstract methods Abstract classes cannot be modified with the final keyword Abstract classes themselves cannot be instantiated Abstract classes are meant to be…

The four major characteristics of JAVA: encapsulation, inheritance, polymorphism, and abstraction

1, Encapsulation Combining the properties and methods of an object into an independent whole, hiding implementation details and providing an interface for external access. Benefits of encapsulation: (1): Hide implementation details. It’s like if you buy a TV, you only need to know how to use it, but you don’t need to understand its implementation principles. (2): Security. For example, if you privatize the age attribute in your program and provide external get and set methods, when the outside world uses the set method When setting a value for an attribute, you can make an if judgment in the set method and set the value between 0 and 80, so that it cannot be assigned at will. (3): Increase code reusability. It’s like various methods encapsulated in tool classes. You can call them repeatedly anywhere without having to implement the details everywhere. (4): Modularization. Encapsulation is divided into attribute encapsulation, method encapsulation, class encapsulation, plug-in encapsulation, module encapsulation, system encapsulation and so on. It is conducive to the division of labor of the program without interfering with each other. It facilitates the combination and decomposition of modules and is also conducive to code debugging and maintenance. For example, the human…

Five steps from beginner to proficient in Java (Java object-oriented, encapsulation, inheritance, polymorphism)

java io Security package string int get static main Write your review! Come on, watch it all Member login | User registration Recommended reading (adsbygoogle = window.adsbygoogle || []).push({}); <!– –> .syntaxhighlighter{ width: 740px; padding-top:40px;padding-bottom:20px; border: 1px solid #333; background: url(“/style/SyntaxHighlighter/top_bg.svg”); background-size: 43px; background-repeat: no-repeat; margin-bottom: -7px; border-radius: 15px; background-position: 16px 12px; padding-left: 10px; } .gutter{ display: none; }

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索