Page 111 - ComputerScience_Class_11
P. 111

objectS




                                               5










                        Learning Objectives


                    5.1 Introduction to Objects                       5.2 Class
                    5.3 Basic Concept of a Virtual Machine            5.4 Basic Input/Output Using Scanner Class from JDK
                    5.5 Errors                                        5.6 Basic Concept of an Exception



                 In the previous chapter, we have read about object-oriented programming and its basic principles. Object-oriented
                 programming has two basic components. They are known as “objects” and “classes”. In this chapter, we will deal with
                 these components in detail.

                     5.1 INTRODUCTION TO OBJECTS

                 Is there anything in the world that is not an object or not associated with an object? The answer is “NO”. Anything
                 we can imagine in the world is an object. Every object has an entity that has a state, behaviour and events. The
                 properties which are associated with an object at any given time contain data. This is called a state. The functionality
                 that an object is supposed to perform is called “behaviour”. Whenever the value of the object changes, it raises
                 events.

                 Suppose, we consider a fan as a real-world object.
                 The properties/characteristics of the object can be:

                 1.  Number of blades (2/3/4)
                 2.  The manufacturing company
                 3.  The speed of the fan

                 The behaviour of the object can be:
                 1.  Switched on/off
                 2.  The speed of the fan should be passed as data by revolving the regulator.
                 The event can be:
                 When the fan revolves, it delivers air. This can be expressed as an event.

                 Thus, an object is a unique entity that contains properties, methods and events in an object-oriented programming
                 language.
                 Let us take another real-life object, a well-known vegetable “radish”.





                                                                                                          Objects  109
   106   107   108   109   110   111   112   113   114   115   116