Programming Concepts Flashcards
Define Object Oriented Programming (OOP).
Programming paradigm that relies on the concept of classes and objects. The classes are used to create individual instances of objects. OOP is organised in a way that reflects the real world. All data and process are in one place; an object.
Define Polymorphism.
The ability of an object to take on many forms. The most common use of this in OOP occurs when a parent class reference is used to refer to a child class object.
AQA: Methods inherited from a base class can be used in different ways depending on the data in the subclass that inherited it. To decipher whether an object is polymorphic, use the “IS-A” test.
W3S: Means many forms. Occurs when we have many classes that are related to each other by inheritance. Polymorphism uses the methods inherited from another class to perform different tasks.
Define Inheritance.
Evernote: Inheritance is the concept that properties and methods in one class can be shared with a subclass.
W3S: Means to inherit attributes and methods from one class to another. The “inheritance concept” is divided into two categories:
- subclass (child): the class that inherits from another class.
- superclass (parent): the class being inherited from.
What is the inheritance key word?
Extends. e.g. class Vehicle { public void honk() { } }
class Car extends Vehicle { }
What is the keyword to prevent classes from inheriting from other classes?
Final.
Why And When To Use “Inheritance” and “Polymorphism”?
It is useful for code reusability: reuse attributes and methods of an existing class when you create a new class.
Define encapsulation.
The concept of putting properties, methods and data into one object.
Define a method.
The cone or routines contained within a class. Also known as a subroutine.
Define an object.
A specific instance of a class.
Define the syntax to create a new object.
MyClass newObj = new MyClass( );
What are the three characteristics of an object?
State: Represents the data (value) of an object.
Behaviour: Represents the behaviour (functionality) of an object such as drive or break.
Identity: An object identity is typically implements via a unique ID. The value of the ID is not visible to the external user.
Define class or object properties.
Properties are the defining features of an object or class in terms of its data.
Define private.
A private attribute can only be accessed within its class.
Define Protected.
A protected attribute can be accessed within its class and derived from class instances.
Define an abstract method.
The actual method is not supplied in the base class, which means it must be provided in the subclass.