Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please dont post anything if you cant do it fully & Thanks Please post answer wh

ID: 3876346 • Letter: P

Question

Please dont post anything if you cant do it fully & Thanks

Please post answer who is expert in Python!! so I wanna answers of Python OOP experts -Describe concisely what an object represents in the context of object-oriented programming, especially in relatiion to a class. Be concise Describe the difference between is-a relationships and has-a relationships. Be concise Describe when to take advantage of inheritance and when to take advantage of composition in object oriented design. Be concise

Explanation / Answer

Ans1:- To understand the concept of object clearly you first have to understand the concept of class.

so class is the collection of data members and memeber function. to access this data member and member function outside the class we required something. so this something is nothing but an object

  OBJECT

An object is an instance of class. when any class is defined, JVM does not allocate any memory to the class.

The momory is allocated only when the object or an instance of the class is created. through this object

you can use any variable or function defined in that particular class.

Ans2:- is-a-relationship:- inheritance is property through which one class inherit the property of the other class.

is a relationship is one kind of inheritance.

Explanation through example:- lets Assume we have one class name Employee.

Class Employee

- Employee_Id

- Employee_name

  let us Assume that you have another class name Permanenrt Employee.

now permanent Employee have its name, employee id and one extra componenet that is LTA.

now instead of defining all three property in Permananet Employee class, we will define only one and extend

that is LTA and rest other two property we will inherit from Employee class

Class Permanent_Employee extend Employee

{  

public int LTA

}

-> it provides code reusebility feature.

Difference Between is-a relationship and Has A relationship.

1. in is-a relationship we use extends keyword and in has -a relationship there is no special keyword

2. in a is-a relationship we try to convey that the object of the child class is of same kind of parent class

or we want to convey that the child class is actulay the parent class with some extra feature.

3. Has-A means an instance of one class “has a” reference to an instance of another class.

4 Has a relationship is also known as “composition” or “aggregation”. but there is no other name of is a relationship

5 Example Has-a Relationship:- Assume there is two class Employee class and Address class. now every employee has an address so we can create the reference of Address class into Employee class and use its property.

Class Employee

{

private Address add

}

Ans3: when both class Parent and child class has same kind of object. for Example Employee and Permananet Employee or a class Account and Saving Account and Current Account.

use is a relationship.

But if the Parent class and child class do not have same type of object like Class Emplyee and Class Address.

where you want to use the property of Address class int Employee class. then use Composition.

Note:- you can see Employee class and Address class can work independently but Employee class and

Permananet class are related to each other.