employer cover photo
employer logo
employer logo

CTS (Computer Technology Solutions)

Acquired by CGI

Engaged Employer

CTS (Computer Technology Solutions) Interview Question

What is the difference between an object and a class?

Interview Answer

Anonymous

Feb 27, 2017

A class is an object, but an object is not always a class. In order for something to be considered an object is must meet two criteria. First, it must have state. Second, it must have behavior. Take for example a bicycle. A bicycle is an object because it has state (e.g. color, weight, length) and it ALSO as behavior (e.g. pedal down, pedal up, change gear), therefore it is considered an object. However, a class is the blueprint for describing the bicycle object. Each bicycle is an "instance" or "object" created from the class, bicycle.