This is the bundling of data and the methods that operate on the data into a single unit called class.
Can be thought of as a template, a prototype or a blueprint of an object
Class
This indicates the access level of attributes and methods. Example: +, -, #
Visibility Notations
Access modifier which restricts access to the same class only.
Private
Complete the object instantiation statement.
Animal dog = new _________();
Animal dog = new Animal();
This represents a group of constants.
enums
This is a type of variable that has the same value for all the objects based from one class.
Class Variables
A whole-part relationship where parts cannot exist independently.
Composition
Access modifier which grants unrestricted access from any parts of the program and referencing programs.
Public
Declare a static modifier for attribute “maxSpeed”.
______ int maxSpeed;
static int maxSpeed;
Which pillar of OOP involves focusing on what an object does rather than how it achieves it?
Abstraction
This is used to initialize values of your class variables.
Constructor Method
A whole-part relationship where parts can exist independently of the whole.
Aggregation
Access modifier which restricts access within the same class and subclasses.
Protected
Which pillar of OOP promotes code reuse and establishes a hierarchical relationship between classes?
Inheritance
If I have a Car class, what should be the name of my constructor method?
Car
The “is-a” relationship between classes where one class derives from another.
Generalization/Inheritance
True or False.
Static Classes can be instantiated.
False
Complete the constructor.
public Car (______ ______, _____ _____){
this.brand = brand;
this.speed = speed;
}
public Car (String brand, int speed){
this.brand = brand;
this.speed = speed;
}
This pillar of OOP enables objects of different types to be treated as objects of a common type.
Polymorphism
These are immutable values which are known at compile time and do not change for the life of the program.
final
This relationship is often used in cases where a class realizes the operations defined by an interface.
Realization
What is the default access modifier in Java?
Package-Private
public class Main{
public static void main(String[] args) {
Example.revealSecretCode();
}
}
class Example {
______ String secretCode = "tama na ma'am!";
static void revealSecretCode() {
System.out.println(secretCode);
}
}
static String secretCode = "tama na ma'am!";