Back to marketplace

Unit 5 - Writing Classes

No description yet. This curated deck is ready for daily study.

Total cards: 24•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (24)

#1
Front (Question)

Access modifiers

Back (Answer)

Affect the access of classes, data, constructors, and methods

#2
Front (Question)

keyword private

Back (Answer)

Restricts access to declaring class

#3
Front (Question)

keyword public

Back (Answer)

Allows access from classes outside the declaring class

#4
Front (Question)

In APCSA, classes and constructors are designated as

Back (Answer)

public

#5
Front (Question)

In APCSA, instance variables are designated as

Back (Answer)

private

#6
Front (Question)

In APCSA, methods can be designated as either

Back (Answer)

private or public

#7
Front (Question)

Computer science creates models of

Back (Answer)

Things that exist in the real world Blueprints -> class Using the class to create instances -> objects Attributes of objects -> instance variables Behaviors of objects -> methods

#8
Front (Question)

public Snack () { name = ""; calories = 0; } This is classified as a

Back (Answer)

Default constructor No values in parameter list

#9
Front (Question)

public Snack (String n, int c) { name = n; calories = c; } This is classified as a

Back (Answer)

Overloaded constructor Values in parameter list

#10
Front (Question)

A class can have what features

Back (Answer)

Private instance variables Public constructors - default, overloaded Methods - accessor, mutator

#11
Front (Question)

Object in another class can call a public method in another class but can’t call a

Back (Answer)

PRIVATE method in another class

#12
Front (Question)

Encapusulation

Back (Answer)

Wrapping the data (variables & code) that acts on dat (methods) in one unit (class)

#13
Front (Question)

We perform encapusulation by

Back (Answer)

Writing a class Declaring instance variables as private Providing access & modifier methods

#14
Front (Question)

Why make instance variables private?

Back (Answer)

Restrict access to read-only Option to provide validation checks

#15
Front (Question)

Object’s state

Back (Answer)

Its attributes & their values at a given time Defined by instance variables belonging to object Creates a “has-a” relationship between object and its instance variables

#16
Front (Question)

Constructors

Back (Answer)

Used to set initial state of object which should include initial values for all instance variables

#17
Front (Question)

Constructor used to set state depends on the way

Back (Answer)

That the object is instantiated

#18
Front (Question)

Only one constructor can be used to set

Back (Answer)

Initial states of instance variables

#19
Front (Question)

Sport tbh = new Sports(); This requires which type of constructor?

Back (Answer)

Default constructor

#20
Front (Question)

Sport wp = new Sport (“Water Polo”, 14); This requires which type of constructor?

Back (Answer)

Overloaded constructor

#21
Front (Question)

Does all instance variables need to be set by parameters?

Back (Answer)

No In some constructors, a portion of instance variables can be set in code body while the rest in the parameter list.

#22
Front (Question)

Parameters in constructors are

Back (Answer)

Local variables only to constructor to which they are sent

#23
Front (Question)

If no constructor is provided, Java provides a

Back (Answer)

default constructor in which all instance variables are set to default values

#24
Front (Question)

The default constructor provided by Java set each data type to what default values

Back (Answer)

int - 0 double - 0.0 Strings/ other - null