AP CSA (Units 3-4) Important Concepts MCQ

0.0(0)
Studied by 0 people
0%Exam Mastery
Build your Mastery score
multiple choiceAP Practice
Supplemental Materials
call kaiCall Kai
Card Sorting

1/22

flashcard set

Earn XP

Last updated 12:27 AM on 5/10/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

23 Terms

1
New cards

what is a field variable and class variable?

field variable and class variables are the SAME THING, and they are both static and belong to the class itself

2
New cards
public class Cat() {
	private static int age;
	private String name;

	public Cat(String name) {
		this.name = name;
		age++
	}
}

If you had this code, what would happen to the class variable “age” each time you create a new object of the class?

The age would keep incrementing because it belongs to the class and not any object.

3
New cards

What are instance variables/methods

Variables and methods that belong to a class but are not static, because it is “instance” they are associated with objects

4
New cards

What are local variable? What is significant about local variables?

Local variables are variables that belong to a method. Once you exit the method, or exit the “{}“, you aren’t able to access these variables anymore so you CANNOT assign access modifiers like public/private to these variables

5
New cards

True/False: methods can access constructor parameters

False, because parameters or local variables only exist within curly braces (scope)

6
New cards

How to directly access a method without creating an object?

Method has to be static. Also classes can never be static

7
New cards

What are static methods not allowed to access in the same class? Also then how would you return it?

They are not allowed to access non-static variables that are in the same class. If you wanted to return the non-static variable, you would have to first create an object of the class and use “.“ to access the variable. For example:

public class Student
{
    private int grade;

    public Student(int g)
    {
        grade = g;
    }

    public static void printGrade(Student s)
    {
        System.out.println(s.grade);
    }
}

You can see that for the parameter of printGrade “s“ is type Student, and we are using OBJECT.INSTANCE_VAR

8
New cards

True/False: normal methods (instance methods) can access any variable

True, only static methods are not allowed to access instance variables (first create an object and use object.instance_name)

9
New cards
public class BoolTest {
    private int one;					
    public BoolTest(int newOne){
        one = newOne;
    }
    public int getOne(){
        return one;
    }
    public boolean isGreater(BoolTest other){
        /* missing code */
    }

What can the instance “other“ access?

It is allowed to access the private variable “one” because it is an object of a method that is in the same class as the class that contains the private variable

10
New cards

How to access an element of an array?

ArrayName[element]

11
New cards

what is the right way to find length of String, ArrayList, and Array?

String: .length()
ArrayList: .size()

Array: .length

12
New cards

When you print an arrayList what does it return?

The real arrayList, and not the address because “System.out.println“ automatically has “toString()“

13
New cards

how to initialize an array

dataType[] name = new dataType(amount);

14
New cards

If you have this line:

newList.add(oldList.remove(1))

what happens to both lists?

the value 1 from oldList is removed, while the value is also added to newList.

15
New cards

What does .get(index) return

the index

16
New cards

what does .set(index, element) return

old element that was replaced

17
New cards

what does .add(element) return

boolean true (usually)

18
New cards

what does .add(index, element) return

nothing (void)

19
New cards

what is the difference between void and null

void is a return type, while null is an actual value (like int, double)

20
New cards

what is autoboxing

when you convert primitive to Object type

Integer age = 5;

21
New cards

how are print statements executed in a recursion?

they are “on hold“ and start printing from the latest statement to the first ever statement because it is in a stack

22
New cards

if the print statement was before the recursion call, what would happen?

cause infinite statements to be printed

23
New cards

if the print statement was after the recursion call, what would happen?

no statements are printed