Personal Reflection In Research

1269 Words6 Pages

Name : Carson Lim Khai Xiang Student ID : 0314435 Personal Reflection Generally from my understanding, Has-a relationship and Is-a relationship are type of relationships to determine themselves within composition and inheritance between objects and instances. Has-a relationship Has-a relationship in an object is called the member of the field, which is also known as aggregation or composition in OOP language. This is to show that object is a composite relationship with another object. There is a tiny difference between aggregation and composition, where composition is when the object and member of the field has a strong association and for aggregation is loosely associated. This means that the object physically has something …show more content…

Inheritance is a type of connection between a class to another one, where the class above is called Parent class and the one below is called Child class. Inheritance allows the parent class to share all the non-private characteristic (the data and methods) to the child class. In order to inherit data and methods from parent class, the child class has to use the keyword “extends” and then the parent class. For example, “Car extends Vehicle” (Car is the Child class & Vehicle is the Parent Class). All the characteristics of Vehicle are passed down to Car. For example, (Vehicle_Speed, Vehicle_Weight and others) is usable in the class …show more content…

Overriding can only happen in the child class and you cannot override method in the same class. The access level cannot be more restrictive than overridden method’s access level, for example if the parent class is declared as public then the overriding method has to be public class as well. If there is no inheritance, there is no method overriding. For example, in my parent class I have (Vehicle’s Speed is 100) in my child class I can override that (Vehicle’s Speed is 180). This method is to allow modification of inherited method without modifying the method in parent class as there could be more than one class that will be inheriting from the same parent class. Abstract class An abstract class is a generic class that declared with “abstract” keyword which creates specific objects that conform to its operations. Abstract classes cannot be instantiated which means that creation of object of Abstract class is not allowed. In an abstract class there can be no abstract methods since there is a default behavior of being overridden by the child class and the methods are usually created in the child class and can be override to make more changes. So, abstract class is useless until it is extended by some other classes.

Open Document