Objets et classes en Java, Variable d'instance en Java
Méthode en Java
Exemple d'objet et de classe qui conserve les enregistrements de l'élève
Dans cette vidéo, nous en apprendrons davantage sur les objets et classes Java. Dans la technique de programmation orientée objet, nous concevons un programme à l'aide d'objets et de classes.
Un objet en Java est une entité physique ainsi qu'une entité logique, alors qu'une classe en Java est une entité logique uniquement.
Qu'est-ce qu'un objet en Java
objet en Java
Une entité qui a un état et un comportement est connue sous le nom d'objet, par exemple chaise, vélo, marqueur, stylo, table, voiture, etc. Elle peut être physique ou logique (tangible et intangible). L'exemple d'un objet immatériel est le système bancaire.
Un objet a trois caractéristiques:
State: représente les données (valeur) d'un objet.
Comportement: représente le comportement (fonctionnalité) d'un objet tel que déposer, retirer, etc.
Identité: une identité d'objet est généralement implémentée via un ID unique. La valeur de l'ID n'est pas visible par l'utilisateur externe. Cependant, il est utilisé en interne par la JVM pour identifier chaque objet de manière unique.
The basic idea of object-oriented programming is to avoid repetition of Java code by bringing together in a single entity called an object the data and the processing that applies to it.
The concept of class: presents the concept and syntax of declaring a class
Objects: presents the creation of an object, its lifetime, cloning objects, object references and comparison, null object, class variables, this variable and the instanceof operator.
Access modifiers: presents the access modifiers of class, method and attribute entities as well as the keywords that qualify these entities
Properties or attributes: presents the data of a class: properties or attributes
Methods: presents the declaration of a method, the transmission of parameters, the transmission of messages, the overloading, the signature of a method and polymorphism and particular methods: constructors, destructor and accessors
The inheritance: presents the inheritance: its principle, its implementation, its consequences. It also presents the redefinition of an inherited method and the interfaces
Packages: presents the definition and use of packages
Inner classes: presents an extension of the Java language which makes it possible to define one class within another.
Dynamic object management: quickly introduces dynamic object management through introspection
The concept of class
A class is the support for encapsulation: it is a set of data and functions grouped together in a single entity. A class is an abstract description of an object. Functions that operate on data are called methods. Instantiating a class consists of creating an object on its model. Between class and object there is, in a way, the same relationship as between type and variable.
Java is an object oriented language: everything belongs to a class except the primitive type variables.
To access a class, you must declare an instance of a class or object.
A class has its declaration, variables and the definitions of its methods.
A class consists of two parts: a header and a body. The body can be divided into 2 sections: declaring data and constants and defining methods. Methods and data are provided with visibility attributes that control their accessibility by components outside of the class.