Week 1 Flashcards
What are the fundamentals of object oriented programming (OOP)?
- Encapsulation and information hiding
- Inheritance and polymorphism
- Decomposition and abstraction
- Dependency inversion
What does write once run everywhere refer to?
The java bytecode (.class) file that is generated from the JVM allows any operating system to run any .java file because the JVM accommodates for the OS when compiling the bytecode file.
What is a class in Java?
The fundamental programming unit of Java. It is a “blueprint” that defines a type, nothing in Java exists outside the class.
In general, what is contained in a class file?
- What data it contains (state stored in variables)
- How to instantiate it (parameters we must pass to the constructor)
- How we interact with it (public methods aka behaviours)
What makes an instance of a class unique?
The attributes in the objects fields at a given moment.
What are the different letter cases of class names, variables and methods, and constants?
Class names: TitleCase
Variables and methods: camelCase
Constants: UPPER_SNAKE_CASE
What does it mean when a programming language is “strongly typed”?
Strongly typed means every “thing” has a type and only certain actions can be performed on certain types.
What does it mean when a program is “statically typed”?
Statically typed means variables need their data type to be declared before assigning anything to it, it also only allows variables to refer/store things of a single data type.
What are the two mandatory components of declaring and initializing variables?
- Data type
- Identifier
What are local variables? When do we assign their values?
Variables that are inside methods. Local variables must be assigned compatible values before they are used.
What are instance variables? Where do we assign their values?
Variables that are inside a class but outside of methods. Instance variables must be assigned values inside the constructor.
What happens if instance variables are not assigned in the constructor?
They will assigned default values depending on their data type.
What are primitive data types in Java?
Primitives are a data type in Java that do not require an object in the heap to be created for them. They are stored wherever they are used.
What are some important properties of primitive data types?
- They can only store data in a specified range
- The size and nature of primitive data types are immutable over all platforms
Briefly described underflow and overflow.
Underflow occurs when you go out of bounds of the range from the smaller “end” and loop back around to the higher end of the range. Overflow is the exact opposite of underflow.
What are the 3 ways to convert data in Java?
- Assignment
- Promotion
- Casting