AP CS A Problem Set #2

studied byStudied by 2 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 24

flashcard set

Earn XP

Description and Tags

For Mr. Lee's class.

25 Terms

1

Class

A blueprint for creating objects that defines its attributes and behaviors Example: public class Song { String title; String artist; }

New cards
2

Object

An instance of a class containing data and methods Example: Song mySong = new Song();

New cards
3

Instance Variable

A variable defined in a class for which each instantiated object has its own copy Example: public class Song { String title; String artist; double cost; }

New cards
4

Constructor

A special method used to initialize objects when a new instance of a class is created Example: public Song(String title, String artist, double cost) { this.title = title; this.artist = artist; this.cost = cost; }

New cards
5

Zero

Argument Constructor

New cards
6

Multi

Argument Constructor

New cards
7

Method

A function defined within a class that describes the behaviors of an object Example: public void play() { System.out.println("Playing " + title); }

New cards
8

toString() Method

A method that returns a string representation of an object's state Example: public String toString() { return "Title: " + title + ", Artist: " + artist; }

New cards
9

Driver Class

A separate class used to test and run methods from another class Example: public class SongDriver { public static void main(String[] args) { Song mySong = new Song(); System.out.println(mySong); } }

New cards
10

Array

A data structure that holds multiple values of the same type in a single variable Example: int[] scores = new int[10];

New cards
11

For Loop

A control flow statement used to iterate over a range of values or elements in a collection Example: for (int i = 0; i < scores.length; i++) { System.out.println(scores[i]); }

New cards
12

Scanner Class

A Java class used for reading input from the user, such as integers, strings, or doubles Example: Scanner scanner = new Scanner(System.in); String name = scanner.nextLine();

New cards
13

Boolean

A data type that represents one of two values: true or false Example: boolean isOn = true;

New cards
14

String

A data type in Java used to store a sequence of characters Example: String message = "Hello, World!";

New cards
15

Encapsulation

The concept of bundling data (attributes) and methods (functions) that operate on the data within a single unit or class Example: public class Account { private double balance; public double getBalance() { return balance; } }

New cards
16

Array of Objects

An array where each element is an instance of a class Example: Song[] playlist = new Song[5];

New cards
17

Default Values

Initial values assigned to variables when no specific value is provided (e.g., 0 for integers, empty string for strings) Example: public Clock() { int hour = 0; String timeZone = ""; }

New cards
18

User Input Validation

The process of checking if the input provided by the user meets certain criteria before processing it Example: if (username.equals("admin")) { System.out.println("Welcome!"); } else { System.out.println("Invalid username"); }

New cards
19

Error Handling

Techniques used to manage and respond to runtime errors in a program Example: try { int number = Integer.parseInt(input); } catch (NumberFormatException e) { System.out.println("Invalid number!"); }

New cards
20

Loop Counter

A variable used to control the number of iterations in a loop Example: for (int i = 0; i < 5; i++) { System.out.println(i); }

New cards
21

Nested Loops

A loop inside another loop, used for multi

New cards
22

Conditionals (If Statements)

A control structure that allows executing certain code blocks based on specific conditions Example: if (age >= 18) { System.out.println("You are an adult."); }

New cards
23

Class Design

The process of defining the structure, methods, and attributes of a class Example: public class Book { private String title; private String author; public String getTitle() { return title; } }

New cards
24

Data Types

Different kinds of data that can be used in a program (e.g., int, double, boolean, String) Example: int age = 20; double price = 19.99; boolean isAvailable = true;

New cards
25

Blackjack Card Game

A game concept used to demonstrate object creation, arrays, and methods Example: public class Card { String suit; int value; public Card(String suit, int value) { this.suit = suit; this.value = value; } }

New cards
robot