What is inheritance
an ‘is-a’ relationship. using regular arrow. inherits the attributes and behaviours of the container. “class mountain bike extends bicycyle'“
what is association
one to many, one to one, many to many. a relationship between classes of objects that allows one object instance to cause another to perform an action on its behalf.
what is aggregation
‘has-a’ relationship. container and contained = customer and bank account. using blank diamond arrow, pointing towards container (opp of inheritance) (container has contained as an attribute)
what is composition
when contained cannot exist without its container. Bank account and sub account, sub account cannot exist w/o bank account. filled-in diamond arrow pointing towards container.
what is a pure association
neither classes have each other as an attribute. a line and 0…n on both ends
what is an object diagram
have actual real-world examples or values. show how a system will look like at a given time
what is an object
representation of a real world entity.
instance of a class.
abstract entity and its components(data and actions).
contains attributes and behaviours
has 2 components: attributes(like lists) and behaviours (functions)
what is a class
template for creating an object. identifies what data needs to be stored for objects of this type and what methods are available to allow access to this data.
advantages of subprograms and objects
support abstraction
facilitating ease of debugging
future maintenance (only need to work through one subprogram instead of whole thing)
reusability of code
modularity
what is abstraction
ignore the irrelevant and focus on the essential qualities of something rather than sticking to one specific example that illustrates our idea
objects are abstracted into a class
what is polymorphism.
methods (behaviours) have the same name but different parameter lists and processes
what is encapsulation
technique of making the states in a class private and providing access to those states via public behaviours (methods)
private = cannot be accessed by any method outside the class, thereby hiding the states within the class
what is dependency
when one class’ methods use a different class. a dotted arrow, from dependent part to the required part.
difference between an object and instantiation
why are dependencies bad
decrease reuse.
reuse helps development speed cuz developers can work on it at the same time.
increases maintenance overheads
changing one line of code could have big impact on all classes involved.
greater room for error and takes lots of time to fix error
explain the need for different data types to represent data items
data is stored as a combination of binary values in the computer
data types are used to store different kinds of data
needed because they specify to the computer how to interpret the binary values in the storage
So computer uses minimum RAM, and the program is more efficient
different types of data and the memory they take up
boolean = data that’s only 2 values (true/ false, on/off). 1 byte
integers = represent whole numbers, 4 bytes bits to store information
real = decimal numbers, 8 bytes
string = sequence of characters like a name, each character takes up one byte
what is declaration
variable declaration with a variable name with an object type
what is instantiation
‘new’ key word used to create the object
what is a super class
class whose features are inherited is known as a super class
what is sub class
class that inherits the other class is known as sub class
can add its own states and behaviours
what are parameters
allows us to pass information or instructions into functions and procedures
names of the information we want to use in a function or procedure
values passed in are called arguments
what is overloading
in a class, different methods have the same name
different signatures where signature can differ but number of input parameters or type of input parameters (or both).
what is overriding
allows child class to provide a specific implementation of a method that is already provided by the parent class
same function, same parameters but different classes
always invokes the more specialized behaviour.
overloading vs overriding
overloading = same function but different parameters
overriding = same function, same parameters but different classes connected through inheritance
advantages of encapsulation
data hiding
increased flexibility
reusability
testing code is easy
what is data hiding as an adv of encapsulation
secure because user can’t see the inner information of the class
not visible to the user how the class is storing values in the variables
only know that we are passing the values to a setter method and variables are getting initialized with that value
what is reusability as an adv of encapsulation
encapsulation also improves ability for code to be used many times
can be copied to different/new classes and help meet new requirements
what is ‘testing code is easy’ as an adv of encapsulation
allows unit testing (automated testing that tests many different types of data quickly
easier to fix larger programs if you know which method is returning the wrong response
what is increased flexibility as an adv of encapsulation
can make variables of the class as read-only or write-only, depending on our requirement
if we wish to make the variables as read-only then we can omit the setter methods
or for variables as write-only then, we omit the get methods
main advantage of inheritance
minimizes amount of duplicate code in an application by sharing common code amongst several subclasses
reduces time and effort to recreate classes by moving that common code up to a common superclass
other advantages of inheritance
minimize amount of duplicate code in an application
better organization of code
code more flexible to change
what is better organization of code as an adv of inheritance
moving common code to a super class result in better organization of code (better abstraction)
what is code more flexible to change as an adv of inheritance
in inheritance classes can be used interchangeably
advantages of overriding
allows a parent class to specify methods that will be common to all of its derivatives
while allowing sub classes to define the specific implementation of some or all of those methods
allow us to call methods of any of the parent classes without even knowing the specifics of the parent class
advantages of overloading
don’t have to create and remember different names for functions doing the same thing
like would have to make many methods names for ever possible combination of parameters being used
advantages of libraries of objects
time saving
sorting algorithms do not have to be re-invented (like u dont have to reinvent the wheel)
complex algorithms and processes can be reused
disadvantages of OOP
increased complexity for small problems
unsuited to particular classes of problems
what is increased complexity in disadvantages of OOP
involves more lines of code than procedural programs
slower than procedure-based programs, as they require more instructions to be executed
what is unsuited to particular problems as disadvantages of OOP
problems can be easily solved by functional programming style, logic programming style, or procedure-based programming style and applying OOP in those situations will not result in efficient programs
ex. why make an object when using a String will do
why is working in a team better
Speed of completion faster
information hiding to reduce module dependencies
expertise in a narrow field
what is speed of completion as an adv of teams
tasks can be completed concurrently, so project completed in shorter amount of time
what is information hiding as an adv of teams
developers only need to know the name and required parameters to use a behaviour
can use code without needing to understand how it functions
security benefit to coders not having access to actual data items
what is expertise in narrow fields as an adv of teams
assembling a complex project needs many skills
each part can be programmed by an expert in that field, so quality of final product is significantly higher than expecting one person to know it all
disadvantages of teams
Communication and coordination issues
Groupthink: diffusion of responsibility; going along
Working by inertia; not planning ahead
Conflict or mistrust between team members
explain the advantages of modularity in program development
easier debugging and testing
speedier completion
code blocks reusable
what is easier debugging and testing as adv of modularity
smaller modules to test means easier to find and fix bugs
number of tests that have to be run to confirm the module is operational is reduced
speedier completion as adv of modularity
breaking the project into smaller modules, can save time by using modules that already exist from libraries that do the function you want
each module can be worked on concurrently, so speedier completion of the overall project
what is reusable code blocks as adv of modularity
some problems are common and possible occur in multiple programs (like needing a text box)
can reuse blocks of code, so development time is slashed
define an identifier
named pointer that explicitly identifies an object, class, method or variable
allows programmer to refer to the item from other places in the program
define primitive
most basic data types available within Java language
boolean, byte, char, short, int, long, float, double
building blocks of data manipulation
purpose: contain pure, simple values of a particular kind
define a variable
named storage location for a value that a program can manipulate
must be declared before they can be used
define instance variable
non -static variables and are declared in a class outside any method, constructor or block
created when object of the class is created and destroyed when object is destroyed
can use access modifiers for instance variables
define parameter variable
parameter allows us to pass information or instructions into functions and procedures
names of the information we want to use in a function or procedure
values passed in are argument
define a local variable
variable defined within a block or method or constructor
created when the block is entered or the function is called and destroyed after exiting from the block or when the call returns from the function
only accessible within its block
define method
set of code referred to by name and can be called at any point in a program simply by utilizing the method’s name
described as a subprogram that acts on data and returns value
each method had its own name
define accessor
type of method returning the value of a private instance variable
getter method
define mutator
setter method
used to control changes to an encapsulated instance variable
define constructor
instance method invoked when object of that class is created (using the new keyword)
same name as class, no return type
class name, object name = new constructor();
difference between constructors and methods
method can be any user defined name
constructor must be class name
method should have return type
constructor doesn’t have any return type
method called explicitly either with object reference or class reference
constructor called automatically whenever object is created
what is a signature
part of the method declaration
combination of the name and the parameter list
__()
define return value
return = reserved keyword in Java, not an identifier
exits from a method, with or without a value
difference between procedures and functions
procedures dont return any value (void)
functions return value
no method can return more than one value at a time in Java
what is an access level modifier
determines whether other classes can use a particular field or invoke a particular method
what is public as a modifier
visible to all classes everywhere
define private as a modifier
can only be accessed within the declared class itself
most restrictive access level
can be accessed outside of class if public getter methods are present
using the private modifier is main way an object encapsulates itself and hides data from the outside world
define protected as a modifier
can be accessed only by subclasses
prevents non related classes from trying to use it
define extends
keyword used in a sub class to inherit the properties of a parent class
define static
means shared between all instances of that class is it belongs to the type, not the actual objects themselves.
takes up less memory cuz only 1 memory allocation for all instances vs 1 per instance
can access the static member without first creating a class instance
how is internationalization done
common character sets among many platforms and languages like Unicode
platform independent high level languages enable code to run on many platforms
what is a moral issue
has the potential to help or harm anyone, including oneself
ex: not testing a product that then fails and causes harm, product failing and causing commercial harm, stealing other programmers’ work
what is an ethical issue
requires you to choose between choices that are right or wrong
ex. responsibility for computer failure, protection of computer property, records and software
what is open source movement
supports the use of open-source licenses for some or all software
voluntarily writing and exchanging programming code for software development
what is a byte
Byte data type is an 8-bit signed two's complement integer.
what is long type
Long data type is a 64-bit signed two's complement integer.
what is double data type
64-bit floating point
what is a char data type
single 16-bit Unicode character