object oreinted p[roggreamoing Flashcards
What is a class
a template for an object it includes attributes
what is an object
an instance of a class. objects have attributes
what is a method
a method is a function or procedure that gives functionality to an object. methods have attributes
what is a constructor
a method that runs when the object is first instated, giving attributes an initial value.
what is the difference between a record and a class
Records can only access attributes directly, whereas classes can only access attributes through a method.
re use or a records code is tricky
re use of a classes code is easy
what is an attribute
a data structure that holds a value for each object (like a variable)
inheritance
when a sub-class takes on the attributes and methods of a superclass
Encapsulation
all attributes are private they are only accessible through methods. this makes the code more robust
polymorphism
occurs when a super class and a subclass both have methods with the same identifier. the sub class overrides the superclass method because of polymorphism
What is abstraction? What are the pros?
(Is when we hide unnecessary detail from a problem.)
The simplification of a problem, for example objects might show up as simple shapes
+Easier to /understand
+Might use less memory
+Reality creates many unneeded details
+Reduces complexity of program code and therefore can run on lower spec computers
Overloading (in polymorphism )
When two or more methods have the same identifier name (within the same class) then the correct method is used depending on the number of parameters