oop Flashcards
(81 cards)
Static vs nonstatic
Static functions belong to the class but not an object of the class, whereas nonstatic functions belong to an object of the class.
Non-static functions must be operated on an instantiated object of the class, static functions do not have to be on an instantiated object.
Hard coding vs soft coding
Hard coding - programmer codes the data
Soft coding - the data collection system codes the data without the programmer
Binary infix operators
+,-,/,*
-15/4 in java
This is equal to -3!
Java associativity?
left to right!
16/4/2 is 2 not 8
What does parseInt or parseDouble do?
Converts an string into the Int or Double that it means.
“9” turns into either 9 or 9.0
escape sequence
\
1 - 0.1 - 0.1 - 0.1 ?
.70000000001
This is due to the way the bits are stored in doubles/floats.
Relational operator meaning
1) == - equal
2) != - not equal
3) < - less than
4) > - greater than
5) <= - less than or equal
6) >= - greater than or equal
if statement inside an if statement
nested if!
What does the new keyword do?
allocates memory at RUNTIME
What is an object?
an abstract data type with state (data) and behavior (code). INSTANCE OF A CLASS.
Encapsulation
An object hides behavior and information from unauthorized users from directly accessing them
…. encapsulation is the BINDING of data, in OOP this refers to how objects store multiple kinds of data
communication from a sender object to a receiver objectvia a link is called a stimulus, andcommunication from a sender class to a receiver class via anassociation is called a message. A stimulus isan instance of a message much the way an object is an instance of aclass and a link is an instance of an association.
True
Abstraction
Capture only those details about an object that are relevant to current perspective. Abstraction is a way to deal with complexity, and hides this complexity from the user.
Allows for ease of development, as you just need to know how to use inputs to receive outputs. “Targetting relevant details for the user”
Inheritance
Object-oriented programming allows classes to inherit commonly used state and behavior from other classes.
How to use inheritance? Purpose of inheritance?
‘extends’ keyword… re-usability of code
USE THIS FOR ABSTRACT CLASSES
Generalization?
A generalization is a form of abstraction whereby common properties of specific instances are formulated as general concepts or claims.
Generalization is the process of extracting shared characteristics from two or more classes, and combining them into a generalized superclass.
If x inherits from b. What is their relationship?
x is a b
Subtyping
implemented or abstracted class is a ‘subtype’
Specialization
specialization means creating new subclasses from an existing class.
Overriding
over-riding or re-writing/changing default behavior of the base class
derived class/base class
derived = sub class base class= super class
Can you instantiate an abstract class? Why or why not?
Abstract classes cannot be instantiated, but they can be subclasses using the ‘extends’ keyword.