OOP Basics
Classes vs Objects
Using a Class as a Client
Writing Classes
Methods, Getters & Setters
100

What does OOP stand for?

Object-Oriented Programming

100

What is a class?

A blueprint or template for creating objects

100

When you use a class written by someone else, what is your program called?

A client

100

What are instance variables also called?

Fields

100

What is an instance method?

A method that operates on a specific object

200

In OOP, what do we organize our code around instead of only functions?

Objects

200

What is an object (or instance)?

A specific version created from a class

200

What is data encapsulation?

Keeping implementation details hidden from the user

200

What is the purpose of a constructor?

To create objects and initialize instance variables

200

What keyword is commonly used to restrict access to instance variables?

private

300

What two main components does every object have?

State and behavior

300

What does it mean to instantiate a class?

To create an object from a class

300

Why don’t clients need to know how a method works internally?

Encapsulation allows users to focus on what a method does

300

What happens if you don’t write a constructor in Java?

Java provides a no-argument constructor

300

What is the general format of an instance method?

visibility returnType methodName(parameters)

400

Give one example of state and one example of behavior for a Rectangle object.

State: width or height; Behavior: calculating area

400

Why is a class often compared to a blueprint?

It defines how objects are built but is not the object itself

400

In documentation, what does the Constructor Summary tell you?

How to create objects

400

Why does each object get its own copy of instance variables?

Each object represents separate data

400

What is the difference between a getter and a setter?

A getter reads; a setter updates

500

Why is Object-Oriented Programming useful compared to only writing functions?

It organizes code around objects, making code easier to manage and reuse

500

Identify which is a class and which is an object: Student and student1.

Student is a class; student1 is an object

500

How does the bank example relate to abstraction in programming?

You use services without knowing internal details

500

What is the purpose of the toString() method?

To return a readable String representation of an object

500

Give two reasons why getters and setters are used instead of public variables.

Validation, safety, abstraction

M
e
n
u