Class is a combination of its Fields and Methods and that is referred to Class Members
Class Car
{
String Color;
String Power;
Void Speed()
{
//Method Definition to calculate Max speed based on it's specifications
}
}
Class Car consist of its member Color and Power and Speed() is a method. You can utilize the same object as many times as you need following the program need. Below is how you can create an object and initialize its members to required specification.
Car carObject = new Car(); //Creating Object of Class Car
carObject.Color = "Blue"; //Initializing fields
carObject.Power = 1000; //Initializing fields
carObject.Speed(); //Method Calling
There are acess modifiers used to restrict the usage of Class members, we will see it in upcoming post. Please stay connected.
No comments:
Post a Comment