AP Computer Science a Flashcards: Objects Instances Of Classes

Study Objects Instances Of Classes in AP Computer Science a with focused flashcards that help you recognize the idea, recall the key rule, and apply it in practice-style prompts.

QUESTION

Which operator is used to check if two references point to the same object?

Tap card or press Space to flip

ANSWER

==. Tests reference equality, not object content comparison.

1 / 38

AP Computer Science a: Using Objects and Methods

All flashcards

38 cards

What this deck covers

This deck focuses on Objects Instances Of Classes, giving you a quick way to review the definitions, rules, and examples that matter most for AP Computer Science a.

How to use these flashcards

Work through these flashcards in short sessions. Try to answer each prompt before flipping the card, then revisit any cards you miss until the explanation feels automatic.

Practice questions

1 of 35Practice questions for this set
Consider the following Java class and code; after executing it, what is the state of checking's balance?
// Bank account management example
class BankAccount {
    private String owner;
    private double balance;

    public BankAccount(String owner, double startingBalance) {
        this.owner = owner;
        balance = startingBalance;
    }

    public void deposit(double amount) {
        balance += amount;
    }

    public boolean withdraw(double amount) {
        if (amount <= balance) {
            balance -= amount;
            return true;
        }
        return false;
    }

    public double getBalance() {
        return balance;
    }
}

class Main {
    public static void main(String[] args) {
        BankAccount checking = new BankAccount("Ava", 200.0);
        BankAccount savings = new BankAccount("Ben", 500.0);

        checking.deposit(50.0);
        savings.withdraw(100.0);
        checking.withdraw(120.0);

        // (No printing here)
    }
}
```​
Choose an answer

Keep your progress across every deck

Free account · cards you mark are saved to it