What's the best way to define the words “class” and “object” to someone who hasn't used them?

前端 未结 29 811
情话喂你
情话喂你 2020-12-13 05:11

My neighbor is taking \"Intro to Java\", and asked me to help explain a few of the first-day concepts. I realized that since I do this everyday, I don\'t have the beginner\

29条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 05:34

    I can say with an example: Animal, Human, car etc. Here Animal, Human, car considered as Class, Now consider Dog: Here Dog considered as Object, who is under Animal class. If we consider a dog, then its state are - name, breed, color, and the behavior are - barking,Eating, running, Sleeping. Now we can say, A class is a blue print of Animal class from which individual object is created. Here barking(), running(), eating(),Sleeping() etc. are method of the particular Dog object. I think it will be little easier to understand the difference between Class and object.

提交回复
热议问题