Paper 2 Flashcards

1
Q

Explain the nature of an object. (3 marks)

A
  • It is an instance of a class
  • Objects will have:
    1. Attributes with initial values
    2. Behaviours/methods/actions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Define an object

A
  • instance of a class
  • created through INSTANTIATION
  • using the ‘new’ keyword
  • which calls the constructor method
  • to allocate memory location for the objects’ initial attribute values
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define a class

A
  • Template/Blueprint for creating objects
  • Has private attributes and public behaviours
  • Encapsulation -using the private attributes that can only be accessed within the same class
  • Private attributes that can be accessed outside the class using public behaviour (accessors and mutators)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the code for creating an object?

A

className objectName = new className();
e.g:
Student Thaniish = new Student();

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

Define Instantiation

A

-Process of object creation from a class
- Uses the ‘new’ keyword which calls the constructor method
- Using the Overloaded constructor - Initialisation -> initial values to the attributes
- Using the default constructor, initialisation is done using mutators

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

Declaration

A

When a data type is assigned to a value

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

Instantiation

A

Using the ‘new’ keyword

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

Initialisation

A

When arguments are applied to an overloaded constructor.

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

What does Decomposition lead to?

A

Modularity

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

What is Modularity?

A
  • Maintainability - one module does not affect another
  • Readability - smaller modules ~> better organisation
  • Reusability - existing modules can be reused across other modules
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the need for decomposition?

A
  • Simplified Debugging
  • Modular
  • Enhanched Reuseability
  • Scalability (updates or extensions)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are dependencies?

A

Relationships

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

What type of dependencies are there?

A
  • Inheritance: ‘is a‘ relationship e.g class subclass extends superclass
  • Aggregation: ‘has-a’ (object creation)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are some negatives of dependencies?

A
  • Maintenance overheads (debugging, recoding)
  • Code complexity
  • Difficulty in debugging
  • Changes in one module requires re-coding another module (cascading impacts)
  • Lack of concurrency (in inheritance superclass needs to be programmed before the subclasses)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the different primitive/basic reference data types?

A
  • char
  • int
  • boolean
  • float/double
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the need for different data types?

A
  • Memory efficient
  • Application -> value assignment
  • Specialised libraries- pre written code, pretested
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What are the types of parameter passing techniques?

A
  • pass by value ~> copy of the variable ~> memory inefficient, changes are not global
  • pass by reference ~> address of the variable ~> memory efficient ~> global
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is encapsulation?

A
  • Data Hiding/data wrapping inside a class
  • Class encapsulates the attributes and behaviours
  • Private attributes which can be accessed outside the class using public behaviours
  • Prevents accidental modifications
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What are some positives of encapsulation?

A
  • Enchanced security
  • Abstraction (hides complexity)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What are some negatives of encapsulation?

A
  • Inefficinet for smaller projects
  • Code complexity
  • Over abstraction (making it too broken down leading to confusion)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is inheritance?

A
  • An OOP feature where a subclass extends the attributes and behaviours from a superclass
  • The subclasses will inherit the common attributes and behaviours
  • The subclass can have its own specific specialised attributes and behaviours
  • In the subclasses, methods from the super class can be overridden for specific functionality
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What are the positives of Inheritance?

A
  • Code Reuse: saves programming time, shorter programs
  • Modularity- superclass prewritten, pretested - was of debugging- maintainability
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Negatives of Inheritance

A
  • Dependency Issues
24
Q

What is Polymorphism?

A

An OOP feature where methods with the same name perform different functions

25
What is overloading?
Static Polymorphism that takes place in: - same class - same method name - different parameters (number, order, type) - different method signatures - no conflict - compile time - method called depends on the argument values passed
26
What is a “libraries of objects”?
- a collection of prewritten and pretested code
27
Advantages of libraries of objects?
- Code Reuse: Efficient programming - Ease of Debugging: Pretested/limited errors
28
What is the use of programming teams?
- Modularity - Concurrent/ Parallel Programming
29
What is overriding?
Static Polymorphism that takes place in: - different classes - same name & parameters - same method signature - no conflict - run time - method called based on the object used to call it
30
Advantages of Programming Teams
- Faster Programming - Enhanced Security - classes have independent modules - Increased efficiency - specialised programming
31
Disadvantages of OOP
- Code complexity: decomposition/ implementing modularity - Not suitable for smaller projects - OOP training is required for developers -> expensive
32
Advantages of OOP
- Maintainability - Reusability - Simulate real world applications - Modularity
33
What is an identifier?
The name of programming elements such as variables, methods, classes
34
What is Object Reference?
The memory address of where the attribute values of the object are atored
35
What is a primitive data type?
A basic data type
36
What is a variable?
Stores a value that can change during execution time
37
What is a constant?
Stores a value that cannot change during execution time
38
What is an instance?
- variables that belong to an object - every object will get a copy of the variable
39
What is a class?
- A template or blueprint to create objects
40
What is the static keyword?
- Shared among the objects of that class - Any changes made by one object will be reflected among other objects
41
What is a parameter?
- Variable that passes values into methods - part of the method signature - it gets values from the arguments in the method call.
42
What does Local mean?
Variables with limited scope/visibility/accessibility within a specific section of code such as methods, loops, classes
43
What is an accessor?
- Getter method (function) for getting the values of the private attributes
44
What is a mutator?
A setter method (procedure) for modifying or initialising the attribute values
45
What is a constructor?
Method used for instantiating an object from the class, called the ‘new’ keyword
46
What are the two types of constructors?
- Overloaded constructors (parameters) - Default constructors (no parameters)
47
What should a method signature contain?
- Name - Parameters list (optional) - Access modifier - Return data type
48
What are access modifiers?
Keywords in the declaration of variables, methods, classes-scope/ visibility/ accessibility/ of the variable/method
49
What are some types of attribute scopes?
- Public: Global access (+) - Private: Within same class (-) - Protected: Within same class (super) and it’s subclasses (#)
50
What does the “This” key-term mean?
- It refers to the variable declared in the class - differentiates between the parameter variable and the variable declared in the class
51
What does the “super()” key word do?
- It is inside the subclass constructor to call the super class constructor
52
What does the “Super” keyword do?
- allows access to the attributes and behaviours of the super class from the subclasses
53
What does the “Final” keyword do?
It prevents edits during runtime
54
What is a reference class?
Prewritten methods/behaviours
55
What types of assessment statements are there?
1. Arithmetic (+,-,*, MOD, DIV) 2. Boolean (&&, ||, !) 3. Relational (>,<) 4. Assignment (=)
56
What types of repetition statements are there?
- Count based - Condition based
57
What is internalisation?
- Using unicode (16+ bits) over ASCII (8 bits)