Programming Concepts Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Define Object Oriented Programming (OOP).

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Define Polymorphism.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define Inheritance.

A

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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the inheritance key word?

A
Extends. 
e.g. 
      class Vehicle {
         public void honk() {                    
  }
}
class Car extends Vehicle {
  }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the keyword to prevent classes from inheriting from other classes?

A

Final.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why And When To Use “Inheritance” and “Polymorphism”?

A

It is useful for code reusability: reuse attributes and methods of an existing class when you create a new class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Define encapsulation.

A

The concept of putting properties, methods and data into one object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Define a method.

A

The cone or routines contained within a class. Also known as a subroutine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Define an object.

A

A specific instance of a class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Define the syntax to create a new object.

A

MyClass newObj = new MyClass( );

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the three characteristics of an object?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Define class or object properties.

A

Properties are the defining features of an object or class in terms of its data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Define private.

A

A private attribute can only be accessed within its class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Define Protected.

A

A protected attribute can be accessed within its class and derived from class instances.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Define an abstract method.

A

The actual method is not supplied in the base class, which means it must be provided in the subclass.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Define a virtual method.

A

The method is defined in the base class but can be overwritten by the method in the subclass where it will be used.

17
Q

Define a static method.

A

The method used can be used without an object of the class being instantiated.

18
Q

Define containment.

A

An outer class contains an instance of another class and allows access tot he contained object through its own methods.

19
Q

Define aggregation (has a).

A

A method of creating new objects that contain existing objects.

20
Q

Define composition aggregation (solid diamond).

A

Creating an object that contains other objects and will cease to exist if destroyed. An example of this is a student object containing grades and attendance. If the student ceases to exist so will the grades and the attendance marks.

21
Q

Define association aggregation (outline diamond).

A

Creating an object that contains other objects, which can continue to exist even if the containing object is destroyed. An example of this is a football team, made up of managers, players and coaches etc. If the football team ceases to exist, them both the players and coaches will simply go to different teams.