Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

An object is a member or an instance of a class. An object has a state in which all its properties have values that you

image text in transcribed

An object is a member or an "instance" of a class. An object has a state in which all its properties have values that you either explicitly define or that are defined by default settings. This subtle conceptual difference between classes and objects shows why there is a tendency to want to use them interchangeably. An example will help clarify what we've said. Suppose we have a class called 'Animal'. All Animals have bodies - and brains these could be the attributes of our fictional Animal class. We can also add some methods that would be common to all Animals - like "movement", because all animals can move (maybe you can think of a better example for methods, but hopefully you get the point). So, the idea you want to enforce in your own mind is that this very general template' of an Animal does not change - it's simply just some lines of code that define the Animal class^1. Objects have a lifespan but classes do not And, as our Animal example clearly shows, every object has a lifespan associated with - it a cat or zebra cannot live forever. And, the properties of those objects can change as well while they 'live'; if we have a 'size' variable defined in the class that would of course change as the cat object grows bigger.^ii Object versus class summary So, we can say that whereas a class is a general concept (like an Animal), an object is a very specific embodiment of that class, with a limited lifespan (like a lion, cat, or a zebra). Another way of thinking about the difference between a class and an object is that a class provides a template for something more specific that the programmer must define, which he/she will do when creating an object of that class. Your own example of a class, and construct 2 different objects from the class you designed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

2. Discuss various aspects of the training design process.

Answered: 1 week ago

Question

5. Discuss the key roles for training professionals.

Answered: 1 week ago