foundational Java concepts including primitive types, operators, control structures, and basic object-oriented programming for AP exam prep.
25 cards
Front
What is the difference between a class and an object?
Back
A **class** is a blueprint or template for creating objects, defining attributes and behaviors. An **object** is a specific instance of a class with actual values for those attributes. Example: 'Dog' is the class; 'Fido' is the object.
Front
What are the 8 primitive types in Java?
Back
The 8 primitive types are: **int**, **double**, **boolean**, **char**, **long**, **short**, **byte**, and **float**. They store raw data values rather than references to objects.
Front
How is the `length()` method different from the `length` property?
Back
In Java, `length` is a property (field) of arrays, as in `arr.length`. `length()` is a method of the `String` class, as in `str.length()`.
Front
What does the `new` keyword do?
Back
The `new` keyword **instantiates** a class by allocating memory for a new object and calling the class's constructor to initialize that object. Example: `String s = new String("hello");`
Front
What is the scope of a local variable?
Back
A local variable is declared inside a method or a block of code (like inside a loop). It is **only accessible** within that specific method or block and ceases to exist when the method or block completes execution.
Sign up to access the full deck with spaced repetition review.
Sign Up — Free