Features of OOP Flashcards
(33 cards)
What is Abstraction
The process of simplifying a situation to only consider relevant details
Benefits of Abstraction
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
What is Inheritance
is when a subclass inherits from the super class as it takes in all its properties and methods.
Benefits of inheritance
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.
What is polymorphism
when a method takes multiple forms
What is overloading
overloading is when a method of the same name in the same class is used but has a different parameter.
What is overriding
when the same method is used in different classes (parent and child) with different behaviours.
When does one overload and when should someone override
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.
explain the difference between overloading and overriding
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
What does the keyword super mean
They keyword super calls the constructor of the super class and initiallizes the inherited fields
what is encapsulation
encapsulation refers to the inclusion of both data and actions into one single component
Benefits of encapsulation
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.
What are access modifiers and what do each of them do
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
what does the key word static mean
The static keyword is used for a constant variable or a method that is the same for every instance of a class.
What is a static variable
A shared class-level data
static method
invoked without an instance and cannot be overriden
When do we use the term this?
to diffrentiate between the parameters and instane variables of a object
what does The term final mean
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
what is a final variable
is immutable once it is assigned
what is a final method
A final method cannot be overridden by subclasses
Primitive data types
a predefined identifier provided by the programming language as a basic building block
what is String class
string class is an object in java, its part of the java language and has methods to help manipulate the data
What is ASCII?
It is a character encoding scheme widely used in computers and communication systems. Uses 7 bits to represent characters, allowing for 128 unique characters.
Disadvantages of ASCII
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