Uploaded by Bailey Bots

Week 1 Notes for Data Structures and Advanced Programming

●
●
●
●
●
●
●
●
●
●
●
●
●
Java is an object-oriented programming language
○ A world consisting of objects that interact with one another
Procedural vs Object-Oriented
○ Procedural is like the program action
○ Object-Oriented is what the program is affecting
Class
○ Determines what kind of data an object is made of
○ What actions the object can take, and how the action is completed
Object
○ Each instance of the class being called (Example: Class is automobile, object is
bobsCar, suesCar, jakesTruck, etc)
Defining a class
○ Public: no restriction on where it can be used
○ Private: only methods within class can refer to it
○ Methods look at or change an objects data fields
○ Get methods look at data field
○ Set methods change value of data field
Methods
○ Abstract: no definition and must be overridden in a derived class
○ Final: cannot be overridden
○ Static: shared by all instances
○ Return type: the type of data the method returns
○ Parameters: values or objects used as inputs
○ Body: java statements
This: given an object, java has a name for it when you refer to the object within the
method definition
Use a variable to refer to an object
Constructors
○ Initialize data fields and allocate memory
○ In absence of explicit info, all fields are set to default values (0, false, null)
Composition
○ Objects are used as data fields
Adapter class
○ Simplify some methods or eliminate others
Inheritance
○ Define general class
Interface type is a reference type