Fundamentals of Programming Flashcards
What is a User-defined data type?
A data type derived from an existing datatype; like an instance of a class.
How do you do an XOR operation?
If same, 0
If different, 1
What is exception handling?
A try-catch; the process of handling errors which occur during runtime – usually causing the program to crash.
What is a class?
A blueprint for creating objects
What is an object?
An instance of a class
What is instantiation?
The process of creating an object
What is encapsulation?
Encapsulation means grouping together related data and methods and controlling access to this data by hiding the implementation details from other parts of the program.
This way, only specific parts of the code can interact with the data, ensuring controlled access and modification.
What is inheritance?
When a child class inherits attributes/methods from a parent class
What is aggregation?
A relationship where one class contains a reference to another class, but both can exist independently.
A weak “has a” relationship. If the object is destroyed, the objects it references will continue to exist.
What is composition?
A relationship where one class contains another class, and the contained class cannot exist independently of the containing class.
A strong “part of” relationship. If the object is destroyed, the ones contained within are also destroyed.
What is function overriding?
When a method is defined in the parent class, then “overridden” in the child class giving it a different functionality.
What is Modulus ?
% - means to find the remainder when a number is divided by another number
What is a benefit of Encapsulation
Encapsulation allows for parts of a program
to be modified without affecting the entire program, as the implementation of methods can be changed without
changing how the methods are used.
What is meant by a virtual method?
You declare it in the parent class:
public virtual void sayHello() {
// Some code here
}
Then in a child class, you override it:
public override void sayHello() {
cw(“Hiiiiii”);
}
What is meant by an abstract method?
You declare it in the parent class, where the class is an abstract class:
public abstract void sayHello();
Then in a child class, you override it:
public override void sayHello() {
cw(“Hiiiiii”);
}