Midterm Review Flashcards
what is the process of Abstraction
o Abstraction
- … is the process of determining the set of features (properties and methods) that a class will have - An Abstract to set the frame work, and classes to create the instances or objects in memory
What are the three pillars of OOPs
Think of them briefly
1/ Encapsulation- Controlling how data and methods can be accessed(private, public, protected, default) 2/ Inheritance - Allowing code from the parent class to be used in the child class(extends/abstract) 3/ Polymorphism - Allows for methods with the same names to be used with a different signature to produce more specialized results!(Overriding)
Differences between Class and Objects
Classes are a collection of code that contains the recipe for object creation, while an object is a constructed object in memory ( WORKSHOP/RAM)
Object attributes And Object behaviors
- Data members
2. Methods ( how they interact)
UML Documentation Diagrams (notes for reading)
- 3 main sections o TOP : defines the class name If it is italicized means it is an ABSTRACT class
o MIDDLE: defines the data members
Also holds the variable names and data type
If underlined that means that it is STATIC
If
- means private
+ means public
# means protected
o BOTTOM: Defines methods aka Behaviors Same identifiers as the middle set Holds constructors Defines method Name then, • What values it accepts and the inputed named • And a return type
Process the use of a tester class ( steps)
a. Create object
b. call getters and setters
c. test methods (overridden, etc)
d. output and check out put!
The 3 P’s - explain the access
o Using the 3 ps Public Accessibility from any class, anywhere Protected Access from any class in the SAME PACKAGE or a SUB CLASS of this class Private No access from outside at all Can bring in other items and change there.
How are constructors different than other methods
Have no return type Matches the class name Require a 0-args constructor Can have matching constructors with different signatures
What is javas default constructor and Interactions with other create constructors
Read - https://www.javatpoint.com/java-constructor
Requires a 0-arg written constructor to be disabled
BUT then the default cant be reused once disabled!
Writing a 0-args Constructor (Think structure)
Public Circle(){ This.radius = 0; } 0-args, public, and a default case set for the objects!
Writing a #-args Constructor
Public Circle(double radius, double circum){ This.radius = radius; This.circum = circum; } think of name shadowing (this < - keyword)
Writing Setter Methods
public void setHeight(int height) { This.height = height } no return type, changes height value
Writing a Getter Method
public int height = 4; public int getHeight() { return this.height; } Does not accept, returns data type of a given variable
Effects of making a data member static or a method
Causes the need to use the class name. vs object. Static links to the class NOT the object Read: https://csawesome.runestone.academy/runestone/books/published/csawesome/Unit5-Writing-Classes/topic-5-7-static-vars-methods.html
Over- ridding vs. Over- loading
Overloading - methods with the same name but Different Signatures
read: https://www.w3schools.com/java/java_methods_overloading.asp
Overriding: is the process of using the same method (return, args, signature) to do another task BASED on the parents version ( think of polymorphism)
Read:https://www.geeksforgeeks.org/overriding-in-java/