100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Class notes

IB Computer Science Resources - Logic Gates, Recursion, Java

Rating
-
Sold
-
Pages
5
Uploaded on
22-03-2025
Written in
2022/2023

Complete collection of resources for IB computer science - Helped me get a 7 in HL Comp Sci

Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Study
Unknown
Course

Document information

Uploaded on
March 22, 2025
Number of pages
5
Written in
2022/2023
Type
Class notes
Professor(s)
Bob q.
Contains
All classes

Subjects

Content preview

OBJECT-ORIENTATED PROGRAMMING

Concept of OOP
Object: An abstract entity with attributes (that describe the entity) and methods it can perform, e.g.
car object's attributes= wheels, windows, brakes etc. Methods= start up, change gear, turn on
headlights etc.

An object is an instance/ instantiation of a class. A class is like a template for an object- code for
the methods and attributes but doesn't take up any memory until an object is instantiated from the
template, with its own copy of the class variables and methods. You can create multiple
instantiated objects from the same class.

Unified Modelling Language (UML)

Class Name
Data / variables / attributes


Actions/ methods




Dependency (“uses” relationship): Implementation of an object depends on/uses one or more
other objects. e.g. Client uses supplier, client is dependent on supplier. Student uses school, bus
uses roads.




Aggregation (“has a” relationship): One object belongs to another and no other object, but both
are independent and can exist without the other. e.g. Car has passengers, but passengers can still
exist and function normally without the car




Composition (“has a”): Like aggregation but the object can't function or exist without the other.
e.g. there can't be a certain department in a hospital if the hospital doesn't exist
Note: Sometimes in IB aggregations and composition are both referred to as aggregation. e.g. could say a
student having hands is an example of an aggregation




Inheritance (“is a”): One object/subclass is a specialised, altered form of another object. It
inherits all the attributes of the parent class, but also has additional ones e.g. Current account is a
type of bank account, bus is a vehicle so has an engine like all vehicles, student is a person so has
a name




Best to reduce dependencies to increase the ability to reuse code. If we depend on another class
to provide useful methods, have to have the parent class/object available whenever we use the
object.

, Data types
 Integer: Stores whole numbers (Java int)
 Real: Stores decimal numbers. Floating point. (Java double or float)
 String: Text data, characters (Java String)
 Boolean: True/ false value (Java boolean)
 Long: Stores a 64-bit integer, can be positive or negative

Data items are passed to and from methods as parameters, which are restricted by pass-by-value
of class relationship. Methods can return at most one data item, e.g. a method that can only return
int or is a void (doesn’t return anything).

Benefits of using different data types...
 Different operations- can be carried out depending upon the type, e.g. calculations with
integer “quantity” variable (can’t do that with a String), Double allows decimals (mirrors real-
life scenarios and allows precise calculations)
 Reduce memory usage- e.g. a whole number takes less space as an integer value than
as a double

Pass-by-value: Means that a value is copied from the main program into the parameter to be used
by the method. If the value (from the parameter) is changed in the method, it doesn’t affect the
original values in the main program. e.g. in Java, the method would have to return the new value,
and then you’d set the original value to the returned value- only then will it change.??
Pass-by-reference: Does not have the value copied into the parameter, only the memory location
(reference/ pointer) is copied. Method can change the variable values in the main program.
[don’t take my word on this one]


Features of OOP

Encapsulation: Data and methods/actions are limited to the object in which they are defined-
places all attributes and methods relating to a certain object/entity together. Private variables can
be used and only accessed outside the class by specific get and set methods.
Advantages
 Class can restrict the way data and methods are altered or called- increases security, since
it ensures variables aren't accidentally changed by another part of the program. Especially
important for team projects.
 Can hide the way data is stored- increase security
 Since relevant attributes/methods are all together, it provides a clearer understanding of
each section of the problem = more efficient programming (faster, less errors etc)

Inheritance: A parent object holds common data and methods for a group of related child objects-
it is extended to create a new object with more properties and methods. The new class can over-
ride old properties and methods in the original class.
Advantages
 Extensibility: Sub-classes inherit methods, can extend them. No need to re-write methods
 Reusability: Changes and upgrades to data and methods in super-class are inherited by
the sub-class, don't need to change each sub-class manually. Less maintenance

Polymorphism: Can have several methods with the same name but different processes- different
versions of the method essentially. If in the same class, must have different parameter lists so the
compiler can tell which one to use according to what values are passed in the parameters. If not in
the same class, compiler selects method in the class currently in use.
e.g. makeSound() is different for different sub-classes of Animal, add() to savings account is
different to add() in current account- current account could take an additional value for
interest rate in its parameters.
$4.12
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
BobQ2

Also available in package deal

Get to know the seller

Seller avatar
BobQ2 Abacus College, Oxford
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
9 months
Number of followers
0
Documents
10
Last sold
-
IB Resource Hub

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions