Download presentation
Presentation is loading. Please wait.
Published byCornelia Fowler Modified over 8 years ago
1
CSE 110 REVIEW Presented By: Samuel Butler & Christina Wilmot
2
Classes and Objects ■What is a class? –A class is a blue print/ template that describes the actions/descriptions of an Object. ■What is an Object? –Objects have states and behaviors. Examples are included through different data types and functions to describe these objects. Button myButtonObj = new Button();
3
What is Static? ■Static members are those that belong to the class instead of a specific instance. ■This means only ONE instance of a static field will exists, even if you create more. This will be shared by all instances. ■Static members CAN accesss instance members through object references.
4
What is THIS? ■Within an instance method/constructor the keyword “this” is used to reference the current object. That is, whichever method or constructor is being called. –Ex: MyObject.printStuff(); ■Here if printStuff contained the keyword THIS, it would refer to the MyObject object. ■Why is this helpful/used? –Disambiguate variable names, Can use as arguments/parameters
5
Method Overloading ■Method Overloading is useful because it allows a class to create more methods that share the same name if their signature is different. ■This means we can keep function names consistent (clean code) while keeping differing functionality. ■Method overloading only works when methods with the same name have DIFFERENT signatures
6
Arrays ■Declaring –Int[] myArray = new int[10]; –Int[] myArray = {1,2,3,4,5,6,7,8,9}; –char[] cArray = {a,b,c,d,e,f,g,h,I,j,k}; ■Indexing/Accessing –myArray[5] = 10; ■Min / Max –myArray[0], myArray[myArray.length -1]
7
Using for loops with arrays ■For loops go hand in hand with arrays. This is because they can index easily, while looping a specified number of times. ■How could we write code to double every number in an array? ■What if we wanted to double every other number in an array?
8
Two Dimensional Arrays ■Two dimensional arrays require a nested (one inside of the other) for loop. ■Make sure you keep different variables in a nested for loop, don’t use I for everything.
9
Selection Sort ■How does it work? –Two different arrays: One sorted, the other unsorted. –We want to look for the smallest number, and add this number to the end of the sorted array. –We do this continuously until the array is sorted.
10
Insertion Sort ■How does it work? –Compare two numbers next to each other starting at the beginning of the array. –If a swap is necessary, swap. –From here check to see if any other swaps are necessary, if so swap again! –Repeat this process until the array is sorted.
11
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.