What is Object-Oriented Programming (OOP)?
A technology for developing reusable software using objects
Why use OOP?
To develop large-scale software and GUIs effectively through reusable components
What is an object?
An entity in the real world that can be distinctly identified, with unique identity, state, and behavior
What is the state of an object?
Properties or attributes represented by data fields with their current values
What is the behavior of an object?
Actions defined by methods that the object can perform
What are data fields?
Variables that represent the properties/state of an object
What is a class?
A template, blueprint, or contract that defines what an object’s data fields and methods will be
What is an instance?
An object created from a class
What is instantiation?
The process of creating an instance/object from a class
What is a constructor?
A special method invoked to create a new object, designed to perform initializing actions
What is the relationship between classes and objects?
A class is a template; objects are instances created from that template (like recipe vs pies)
What is UML?
Unified Modeling Language - a notation for representing classes and objects in diagrams
What is a class diagram?
A UML diagram showing class name, data fields, constructors, and methods
How are data fields denoted in UML?
dataFieldName: dataFieldType
How are constructors denoted in UML?
ClassName(parameterName: parameterType)
How are methods denoted in UML?
methodName(parameterName: parameterType): returnType
What is a main class?
A class that contains the main method and can be run
Can a class without a main method be run?
No, it’s merely a definition for objects
What is a client of a class?
A program that uses the class to create and manipulate objects
What is a public class?
A class declared with public modifier, accessible from any other class
How many public classes can be in one file?
Only one, and it must have the same name as the file
What files are generated when compiling a Java file with multiple classes?
A separate .class file for each class in the source file
What are the three peculiarities of constructors?
1) Same name as class 2) No return type 3) Invoked using new operator
What is a no-arg constructor?
A constructor without arguments, often providing default values