extraa Flashcards
Why close files?
When a file is “opened,” the operating system marks the file as locked, generally so it can’t be deleted by other processes while it’s being used. myFile.close() undoes the lock, allowing the operating system and other processes to do what it wishes with the file. It also releases any system resources associated with the stream.
What happens if a parameter is passed by value?
a copy of the variable is passed to the subroutine where it is treated as a local variable thus protecting it from being changed by the subroutine but also using additional memory space. It is destroyed when the subroutine has completed.
What happens if a parameter is passsed by reference
the reference to the memory location of the variable itself is passed Therefore if the value of the variable is changed, it remains changed after the subroutine ends. A literal value can’t be passed by reference obviously as it has no reference (more applicable to recursive subroutines).
If it is not stated will parameters be passed by value or by reference
By value
How do you do by value and by ref?
procedure calculateTotal(x:byVal, y:byRef)
What is encapsulation?
All of the object’s attributes are contained and hidden in the object by giving them the private access modifier. They are accessed through public getter and setter methods.
What is instantiation?
The process of creating an instance of a class.
What is a class?
A blueprint for creating an object.
What is an access modifier?
For example public and private which can be applied to attributes and methods in the class. Private means the attribute or method can not be accessed by code in another class while public means it can.
What is an atribute?
A specific piece of data representing a particular characteristic of an object.
What is a constructor?
A method that is called when creating an instance (object) of a class.
What is an object?
Instance of a class
What is OOP?
A programming paradigm which classifies real world objects into classes and encapsulates the object’s attributes and behaviours.
What are methods?
for example getters and setters and other subroutines that define the behaviour of the object.
What is inheritance?
A mechanism that allows an instance of a class to inherit attributes and methods from another class (the superclass/parent class). It can also have methods/attributes of its own.