Answer the following questions.
1. Give two examples of real world objects. Also specify their characteristics and behaviour.
2. What do you understand by state of an object? Explain with an example.
3. How are objects implemented in Software?
4. What is abstraction? How is encapsulation related to it?
5. Define Encapsulation.
6. Explain the term object using an example.
7. What is Object Oriented Programming?
8. State three differences between Procedure Oriented Language and Object Oriented Language.
9. Name the four characteristics/principles of Object Oriented Programming.
10. Give a real life example of Polymorphism.
Answers
Answer:
1)Look around right now and you'll find many examples of real-world objects: your dog, your desk, your television set, your bicycle. Real-world objects share two characteristics: They all have state and behavior. Dogs have state (name, color, breed, hungry) and behavior (barking, fetching, wagging tail).
2)... An object is an entity that has state, behavior, and identity. The structure and behavior of similar objects are defined in their common class. ... The state of an object encompasses all of the (usually static) properties of the object plus the current (usually dynamic) values of each of these properties ...
3)Software objects are modeled after real-world objects in that they, too, have state and behavior. A software object maintains its state in variables and implements its behavior with methods.
4)Abstraction (from the Latin abs, meaning away from and trahere , meaning to draw) is the process of taking away or removing characteristics from something in order to reduce it to a set of essential characteristics. ... Abstraction is related to both encapsulation and data hiding.
Encapsulation enables you to hide the code and data into a single unit to secure the data from the outside world. You can use abstraction using Interface and Abstract Class. You can implement encapsulation using Access Modifiers (Public, Protected & Private.) Focus mainly on what should be done.
5)In object-oriented programming, encapsulation refers to the bundling of data with the methods that operate on that data, or the restricting of direct access to some of an object's components.
6)An object, in object-oriented programming (OOP), is an abstract data type created by a developer. It can include multiple properties and methods and may even contain other objects. In most programming languages, objects are defined as classes. ... A simple example of an object may be a user account created for a website
7)Object-oriented programming is a programming paradigm based on the concept of "objects", which can contain data, in the form of fields, and code, in the form of procedures. A feature of objects is that an object's own procedures can access and often modify the data fields of itself.
8)In procedural programming, program is divided into small parts called functions. In object oriented programming, program is divided into small parts called objects. Procedural programming follows top down approach. Object oriented programming follows bottom up approach
9)Object-oriented programming has four basic concepts: encapsulation, abstraction, inheritance and polymorphism
10)Real life example of polymorphism: A person at the same time can have different characteristic. Like a man at the same time is a father, a husband, an employee. So the same person posses different behaviour in different situations. This is called polymorphism
Answer:
1. The first object of real world objects is a car, its characteristic is represented by its colour, its length and breadth, number of people that can sit, the wheel radius,and its behaviour is the speed, how fast it can go from one place to another, the amount of steering control it can have.
The book that we are reading now is another example of an object characteristics. Its characteristics is represented by the information it holds, size, volume and its colour. The behaviour aspect comprises the method of accessing the information it contains.
2. The state of an object is the value of attributes or data members.
Thus, a group of objects may have the same characteristics and behavior, yet the object could be distinguishable from each other as the value of their attributes may be completely different from each other.
For example, the book may be kept open with someone, open to a certain page with someone or open to a different page with someone.
Explanation: