#04 Classes, Methods, Constructors and Objects in Java | Understanding Classes, Methods, and Object

Опубликовано: 05 Ноябрь 2024
на канале: Sachii Online Academy
220
13

#04 Classes, Methods and Objects in Java | Understanding Classes, Methods and Objects in Java
You can buy me some coffee using ecocash, Innbucks, 1money, visa card, master card etc, just click this link to pay now: https://bit.ly/sachiionlineacademydonate
previous video:    • #03  Java Variables ? | Understanding...  
Subscribe for more videos!    / @sachiionlineacademy  

1. Classes in Java?
A class is a blueprint from which individual objects are created.
A class is an abstract description of objects
Here is an example class:
class Dog { ...description of a dog goes here... }

2. Objects in Java?
If we consider the real-world, we can have cars, dogs, humans, etc.
All objects have a state and a behavior
If you compare the software object with a real-world object, they have very similar characteristics.
Software objects also have a state and a behavior.
3. Constructors in Java
In Java, a constructor is a block of codes similar to the method and it is called when an instance of the class is created
It is a special type of method which is used to initialize the object.
Every time an object is created using the new() keyword, at least one constructor is called.