Exam 1 Flashcards
Java Workflow
Compile source code -> Check syntax errors -> Execute bytecode -> Check runtime errors -> Finished
UML (Unified Modeling Language) meanings
All Caps : Constant # : Protected \+ : Public - : Private Italics : Abstract Underline : Static Hollow diamond : Aggregation Filled diamond : Composition Hollow triangle : Inheritance
UML (Unified Modeling Language) use
Used for visualizing classes
Javadoc commenting use
Comment on class Comment on member variables Comment on constructors Comment on all methods Use @ symbol with tags to describe specific things (such as parameters and returns)
Primitive versus reference data types
Primitive: Set amount of space that is directly pointed to
Reference: Don’t know size of, point to reference/address of object
Static versus instance
Instance: Unique to each object
Static: Not unique to each object, shared among them. Static methods don’t rely on objects either
Can you have multiple classes within a single file?
Yes however, only one class can be public
Aggregation versus composition versus inheritance
Aggregation: ‘Has-a’ relationship but, not dependent on each other
Composition: ‘Has-a’ relationship but, dependent on each other
Inheritance: ‘Is-a’ relationship
Using final on classes and methods
Final class: Class cannot be inherited from
Final method: Method cannot be overridden
How does abstraction fit into polymorphism?
We can use abstraction for reference types but not object types (EX: Shape test = new Rectangle();)
What are the two things interfaces can only contain?
Static constant member variables
Abstract Methods
Can interfaces extend other interfaces?
Yes, however they cannot extend classes
Four principles of Object Oriented Programming
Abstraction
Encapsulation
Inheritance
Polymorphism
What is the purpose of abstraction?
It eliminates the unnecessary, and amplifies the essential
What is the purpose of encapsulation?
It hides the unnecessary