IB Computer Science OOP
what is aggregation?
"has a" relationship between two classes where an object of one class has an object of another. example: public class Classroom {private Teacher teacher; // Classroom has a Teacher}
what are advantages of object libraries?
- code reusability - complex algorithms do not need re-invention - efficiency
what are advantages of inheritance?
- code reusability - extensibility - easily maintained
what are disadvantages of OOP?
- overly complex for simple problems - tendency of over abstraction
what are the three types of variables?
- parameter variable - instance variable - local variable
what are the advantages of modularity in program development?
- productivity - usability - easily maintained - code reusability
what are two characteristics of an object?
- state (Variables) - behaviour (Methods)
what are advantages of polymorphism?
- uniform interface - extensibility - code reusability
what is a constructor?
A constructor method is a method that creates one instance of a class (i.e. an object)
what is a primitive data type and what are the 8 different ones?
A value that is predefined by the language and is named to a reserved keyword - byte : 8 bit signed number variable - short : 16 bit signed number variable - int : 32 bit signed number variable - long : 64 bit signed number variable - float : 32 bit decimal value - double : 64 bit decimal value - boolean : true or false - char : single character
what is a method's signature?
Refers to the method name and the number and type of its parameters. Return types and thrown exceptions are not considered part of the signature
Define Unified Modelling Language (UML)
a diagram that provides a way to visualize the design of any software system,
define "super"
a keyword used to call a method from a parent class.
what is an accessor?
a method that is used to obtain information about an object and is also used in order to access the data in that object . (getter)
what is a parameter and what are the two types?
a value that is passed to a method for it to use. formal and actual parameters
define protected
access modifier keyword meaning that a method, variable or constructor can only be accessed by the subclasses in another package or any class within the member class
what is polymorphism?
allowing values of different data types to be handled using a uniform interface
define "overloading"
an example of Polymorphism in which methods of the same name but different formal parameters can be called depending on the actual parameters used.
define "overriding"
an example of Polymorphism in which methods of the same name in a sub-class can take precedence over the method in the parent class.
What is the difference between an object and a class?
an object is an instance of a class
why should to dependencies between objects be reduced?
because they decrease reusability
what is class decomposition?
breaking a programming problem into multiple classes where each class has a specific task to perform in solving the problem.
what is a mutator?
is a method that is used to set a value of a private field that cannot be publicly accessed. (setter)
what is a method?
is a part of a program that executes java code. It is not to be confused with a constructor method.
what is an instance variable?
its declared in a class, but outside a method, constructor, or block and hold values that are referenced by many parts of the program
what is a local variable?
its declared in methods, constructors, or blocks and are only visible within them.
define static
keyword meaning that a member variable or method can be accessed without requiring an instantiation of the class to which it belongs.
define extends
keyword used when you want a class or object to inherit from another class or object.
define public
least restrictive access modifier keyword meaning that a class, method, variable, constructor or interface can be accessed from any other class
define private
most restrictive access modifier keyword meaning that a method, variable or constructor can only be accessed within the declared class
what is a formal parameter?
parameters in the header of the method declaration are called formal parameters and they are limited to the method they are declared in
what is inheritance?
programming one class to be extended to other classes; sub-classes inherit all of the super classes attributes and functions.
what is encapsulation?
protecting of data by making attributes private and therefore can only be worked with indirectly through specific public methods
what are advantages of encapsulation?
simplified interaction between objects - hiding the details of an objects internal functions - protects object data and functions from accidental corruption
what is a class?
the blueprint from which individual objects are created
define "abstraction"
the process of creating complex data types and only selecting relevant operations to interact with that data type.
what is an identifier?
the referable name of variables, methods, classes, packages, and interfaces
what does it mean to instantiate an object?
using a class's constructor to create an instance of an object. in Java you use the keyword new. example: Student student = new Student("John", "Wayne");
what is an actual parameter?
values passed into a method are called actual parameters or arguments