A collection of methods with no implementation is called what in java?
Interface
Interfaces in java are used to declare a behaviour that a class must implement.
What type of attribute or method cannot be accessed from outside a class?
Private
What type of attributes and emthods can be acessed anywhere in a program?
Global
What type of attributes and methods can be acessed from outside the class?
public
Adding new code to a procedurallyprogrammed program is difficult
Adding new code to an object orientated program is easy
In procedural programming it is easy to write a program that can be used in numerous ways
Both procedural programming and OOP use abstraction
2 examples of procedural programming languages are C and Pascal
2 examples of OOP languages are:
Java
C#
In OOP it is easy to encapsulate data so it cannot be accessed from outside the class
Inheritance is using another classes methods and attributes in a new sub/child class
Polymorphism is having a method that can be used for multiple things
Class diagrams use arrows to show inheritance
Encapsulation is when an object controls it's own state and is therefore seperate from the program especially in OO programming languages, in which attributes and methods can be made private, making it only possible to reference them within a class
Dunder stands for double underscore and is used when constructing a class (__init__) but can also do what?
Override certain inbuilt methods and attributes such as __add__ or __name__
An example of dunder with addition is
class Animal:
def __init__(self, name):
self.name = name
def __add__(self, another_animal):
return Animal(self.name + another_animal.name)
print('horse' + 'penguin')
Would print?
horsepenguin
ABC is abstract base class and is used to create abstract classes which define a framework for other classes
An abstract class can use abstract methods to what?
Require a sub class defines that method or an attribute error will be returned
An abstract method cannot be?
Passed
public object data can be accessed from anywhere
Protected classes can be indicated in python with a single underscore before the method or attributes name