1,471
8
Essay, 2 pages (350 words)

Example of objects instances essay

Objects (Instances)

Objects are the building blocks of the Java programming language being an object-oriented language. An object is just like real-world objects and their description and properties are described in the object class. An object can be composed of several other objects. The limitations of the properties or the description of an object is based on its class descriptions, its methods and properties set.

An instance of an object is one specific occurrence of the specific object where all the properties and behavior of the object class are inherited. An object reference called the instance of the object is returned when the java object constructor is called. One the object constructor is called, an instance of the object it represents is returned. Instances of objects interact with other objects by invoking their respective methods. Instances of objects are can be created and destroyed while the program runs

Consider the following code:

Bicycle{

}

public Bicycle {

int speed = 30;

}

public void getSpeed{

return speed();

an instance of the class bicycle can be created by calling the constructor of the object

Bicycle AlexBicycle = new Bicycle();

Bicycle MyrnaBicycle = new bicycle();

In the code above, two instances of the class Bicycle are created. They have the same properties but they can have different values. For example if the following code is added

MyrnaBicycle. getSpeed = 20;

AlexBicycle. getSpeed = 30;
sets the speed of MyrnaBicycle to 20 and AlexBicycle to 30.

Since objects and object instantiation are one of the main features of object-oriented programming it just reflects that the the benefits of using object-oriented programming are also aligned in the benefits of using Object instances. One of the major benefits is its reuse capability. You can create several instances of a class in a single program without creating additional code for the object class. Automatically, all the properties of the class are inherited by each instance of the class. This also follows that using objects instances is very maintainable since if one wants to set new propertied of a class then only one code needs to be changed even of there are hundred of instances of the object.

References:

Objects, Instance Methods, and Instance Variables. Retrieved from http://math. hws. edu/javanotes/c5/s1. html

Thank's for Your Vote!
Example of objects instances essay. Page 1
Example of objects instances essay. Page 2
Example of objects instances essay. Page 3
Example of objects instances essay. Page 4

This work, titled "Example of objects instances essay" was written and willingly shared by a fellow student. This sample can be utilized as a research and reference resource to aid in the writing of your own work. Any use of the work that does not include an appropriate citation is banned.

If you are the owner of this work and don’t want it to be published on AssignBuster, request its removal.

Request Removal
Cite this Essay

References

AssignBuster. (2022) 'Example of objects instances essay'. 10 September.

Reference

AssignBuster. (2022, September 10). Example of objects instances essay. Retrieved from https://assignbuster.com/example-of-objects-instances-essay/

References

AssignBuster. 2022. "Example of objects instances essay." September 10, 2022. https://assignbuster.com/example-of-objects-instances-essay/.

1. AssignBuster. "Example of objects instances essay." September 10, 2022. https://assignbuster.com/example-of-objects-instances-essay/.


Bibliography


AssignBuster. "Example of objects instances essay." September 10, 2022. https://assignbuster.com/example-of-objects-instances-essay/.

Work Cited

"Example of objects instances essay." AssignBuster, 10 Sept. 2022, assignbuster.com/example-of-objects-instances-essay/.

Get in Touch

Please, let us know if you have any ideas on improving Example of objects instances essay, or our service. We will be happy to hear what you think: [email protected]