Midterm Review Flashcards

1
Q

what is the process of Abstraction

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the three pillars of OOPs

Think of them briefly

A
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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Differences between Class and Objects

A

Classes are a collection of code that contains the recipe for object creation, while an object is a constructed object in memory ( WORKSHOP/RAM)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Object attributes And Object behaviors

A
  1. Data members

2. Methods ( how they interact)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

UML Documentation Diagrams (notes for reading)

A
-	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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Process the use of a tester class ( steps)

A

a. Create object
b. call getters and setters
c. test methods (overridden, etc)
d. output and check out put!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The 3 P’s - explain the access

A
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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How are constructors different than other methods

A
Have no return type 
Matches the class name
Require a 0-args constructor
Can have matching constructors with different signatures
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is javas default constructor and Interactions with other create constructors

A

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!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Writing a 0-args Constructor (Think structure)

A
Public Circle(){
	This.radius = 0;
}
0-args, public, and a default case set for the objects!
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Writing a #-args Constructor

A
Public Circle(double radius, double circum){
	This.radius = radius;
        This.circum = circum;
}
think of name shadowing (this < - keyword)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Writing Setter Methods

A
public void setHeight(int height)
{
     This.height = height
}
no return type, changes height value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Writing a Getter Method

A
public int height = 4;
public int getHeight()
{
      return this.height;
}
Does not accept, returns data type of a given variable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Effects of making a data member static or a method

A
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Over- ridding vs. Over- loading

A

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/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Meaning of more Abstract or more Concrete

A

abstract: meaning building blocks or not the end product (animal, farm animal - animal classes)
Concrete: meaning the end goal or implement final structure ( Dog, Cat, Cow - animal classes)

17
Q

What are abstract classes and methods used for!

A

These classes and methods force the coder to implement them in other child classes
THINK OF CONTRACTS

18
Q

Polymorphism

A

o Named after shape shifters, and also named Late binding
CONCEPT: using methods with the same names to do more specialized taskes
Uses method over-ridding
JVM compares the method call with the class that called it to determine how to handle the call!

19
Q

IS-A relationship vs. HAS-A

A

IS-A: KEYWORDS(extends, implements)
“A is a B type of thing”. For example, Apple is a Fruit, Car is a Vehicle etc. Inheritance is uni-directional. For example, House is a Building. But Building is not a House.
HAS-A: NO KEYWORDS
means the use of a instance of a class!
https://www.w3resource.com/java-tutorial/inheritance-composition-relationship.php

20
Q

Aggregation vs. Composition

A

Aggregation implies a child that can live independently of the parent;

Composition implies a child requires a parent to exist

21
Q

Early Binding

A

-Happens during compile time
-Is not true polymorphism
- Actual object isnt used in binding
Examples: Overloaded

22
Q

Late Binding

A
  • Done in runtime
  • actual object used for binding
    Examples: Overriden
    Non static