Features of OOP Flashcards

(33 cards)

1
Q

What is Abstraction

A

The process of simplifying a situation to only consider relevant details

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

Benefits of Abstraction

A

helps create modular code by breaking down complex systems into smaller simpler units making the code more organized.
Additionally it also helps code comprehension as abstraction hides unneccessary information allowing developers to put their focus towards relevant information making it easier for them to understand

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

What is Inheritance

A

is when a subclass inherits from the super class as it takes in all its properties and methods.

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

Benefits of inheritance

A

Child classes inherit data and actions from the superclass, therefore, the child class can add new functionality or redefine the data and actions to better suit the sub class
Additionally, inheritance helps in maintanence as in the event that the super class has to be altered, the subclasses will not need to also be altered, saving time.

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

What is polymorphism

A

when a method takes multiple forms

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

What is overloading

A

overloading is when a method of the same name in the same class is used but has a different parameter.

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

What is overriding

A

when the same method is used in different classes (parent and child) with different behaviours.

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

When does one overload and when should someone override

A

one should over load if
When you want to create multiple methods with the same name but different parameters (different number or types).
when there are different inputs needed for similar behaviour
not suitable for customizing behaviour based on different method signatures in the same class

one should override if
When you want to change the behavior of a method in a subclass that is already defined in a parent class.

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

explain the difference between overloading and overriding

A

overloading is when a method of the same name in the same class has different parameters
Overriding however is when the same method is used in different classes with different behaviours

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

What does the keyword super mean

A

They keyword super calls the constructor of the super class and initiallizes the inherited fields

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

what is encapsulation

A

encapsulation refers to the inclusion of both data and actions into one single component

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

Benefits of encapsulation

A

Modularity as for a programmer they dont need to know how the class is storing its name field
the programmer of class Person can change the inner workings of the class provided the methods behave the same so that no external code should break as a result.

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

What are access modifiers and what do each of them do

A

access modifiers are essential tools that define how the members of a class, and even the class itself can be accessed from other parts of our program.

these are

public, any class can access it
private, only the super class can access it
protected, only the superclass and its subclasses can access it

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

what does the key word static mean

A

The static keyword is used for a constant variable or a method that is the same for every instance of a class.

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

What is a static variable

A

A shared class-level data

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

static method

A

invoked without an instance and cannot be overriden

17
Q

When do we use the term this?

A

to diffrentiate between the parameters and instane variables of a object

18
Q

what does The term final mean

A

Final is used to create a constant in Java
Constants are usually class variables instead of instance variables but in some cases they are instance variables

19
Q

what is a final variable

A

is immutable once it is assigned

20
Q

what is a final method

A

A final method cannot be overridden by subclasses

21
Q

Primitive data types

A

a predefined identifier provided by the programming language as a basic building block

22
Q

what is String class

A

string class is an object in java, its part of the java language and has methods to help manipulate the data

23
Q

What is ASCII?

A

It is a character encoding scheme widely used in computers and communication systems. Uses 7 bits to represent characters, allowing for 128 unique characters.

24
Q

Disadvantages of ASCII

A

the disadvantage of ASCII is that many languages contain many more characters, its bit range is very small allowing for only 128 unique characters which means languages with more characters are limited when using ASCII and its mainly useful only to the english language

25
the solution of ASCII
Unicode expands upon the limitations of ASCII by using a larger bit range, allowing it to represent a vast number of characters (over 1 million) from various languages and scripts.
26
pass by value
Pass by value is a method of passing arguments to functions where a copy of the actual value is made and passed to the function. This means that any changes made to the parameter inside the function do not affect the original variable outside the function.
27
What are libraries of objects?
They are collections of classes that have already been written in code and can be used by a programmer while developing a program.
28
Advantages of libraries of objects
Reusable classes and methods eliminate the need to write code from scratch Ensures reliability; Libraries contain tested and proven code, reducing bugs
29
Disadvantages of OOP
For small projects, with few developers and modules OOP may increase complexity, development time and maintenance costs. Programming in OOP requires care in order not to make projects too abstract which lead to unnecessarily large and complex programs
30
use of individual programmer (Positive and negative)
Positive Have an overall view of the whole project and able to make changes quickly| Does not need to develop a common language with his/her peers, since there is no collaboration and coordination needed Negative Not suitable for bigger projects as developer would need much more time than available to complete the project on time.
31
use of groups of programmers
Positives Larger projects can be taken, since more developers can work on them Compared to solo developers member of a team may bring various ideas to the table that would not have come about without member collaboration Negatives The weaknesses of some team members may end up undermining the group Decisions and planning takes longer
32
Advantages of modularity in program development
A sub-program developed for one application may be used in other (log in, user profile, google functions) applications that need to have the same functionality Less new code need to be written for a program
33
Moral and ethical obligations of programmers
Thoroughly test their products before providing them to the public. This ensures they operate as expected and any possibility of commercial or other damage has been minimized. Obliged to give credit to the intellectual property of others when they include such work in their projects.