Introduction to Algorithms, Programming, and Compilers - AP Computer Science A
Card 1 of 30
Identify the method to find string length in Java.
Identify the method to find string length in Java.
Tap to reveal answer
length(). Returns character count in the string.
length(). Returns character count in the string.
← Didn't Know|Knew It →
What is the output of: System.out.println(2 + "3");?
What is the output of: System.out.println(2 + "3");?
Tap to reveal answer
- String concatenation occurs with + operator.
- String concatenation occurs with + operator.
← Didn't Know|Knew It →
Identify the method to find string length in Java.
Identify the method to find string length in Java.
Tap to reveal answer
length(). Returns character count in the string.
length(). Returns character count in the string.
← Didn't Know|Knew It →
Find the logical error in: if (x = 5) {...}
Find the logical error in: if (x = 5) {...}
Tap to reveal answer
Use '==' for comparison, not '='. Assignment operator used instead of equality.
Use '==' for comparison, not '='. Assignment operator used instead of equality.
← Didn't Know|Knew It →
What is the base case in recursion?
What is the base case in recursion?
Tap to reveal answer
The condition under which recursion stops. Prevents infinite recursion by terminating calls.
The condition under which recursion stops. Prevents infinite recursion by terminating calls.
← Didn't Know|Knew It →
Identify the primary purpose of a compiler.
Identify the primary purpose of a compiler.
Tap to reveal answer
To translate source code into machine code. Compilers convert high-level code to executable format.
To translate source code into machine code. Compilers convert high-level code to executable format.
← Didn't Know|Knew It →
What is a programming language?
What is a programming language?
Tap to reveal answer
A formal language used to write algorithms. It provides syntax and semantics for creating software.
A formal language used to write algorithms. It provides syntax and semantics for creating software.
← Didn't Know|Knew It →
What is 'machine code'?
What is 'machine code'?
Tap to reveal answer
Binary code that a computer's CPU can execute directly. Consists of 1s and 0s that processors understand.
Binary code that a computer's CPU can execute directly. Consists of 1s and 0s that processors understand.
← Didn't Know|Knew It →
State the function of an interpreter.
State the function of an interpreter.
Tap to reveal answer
To execute code line by line and translate it into machine language. Unlike compilers, interpreters process code at runtime.
To execute code line by line and translate it into machine language. Unlike compilers, interpreters process code at runtime.
← Didn't Know|Knew It →
What is a 'null pointer exception'?
What is a 'null pointer exception'?
Tap to reveal answer
An error when accessing a method or field of a null object. Occurs when dereferencing null object references.
An error when accessing a method or field of a null object. Occurs when dereferencing null object references.
← Didn't Know|Knew It →
What is the result of: 'Hello'.charAt(1)?
What is the result of: 'Hello'.charAt(1)?
Tap to reveal answer
e. Returns character at index 1 (second position).
e. Returns character at index 1 (second position).
← Didn't Know|Knew It →
What is an interface in Java?
What is an interface in Java?
Tap to reveal answer
A reference type that can contain only abstract methods. Cannot be instantiated, only implemented.
A reference type that can contain only abstract methods. Cannot be instantiated, only implemented.
← Didn't Know|Knew It →
What is the default value of a boolean in Java?
What is the default value of a boolean in Java?
Tap to reveal answer
false. Boolean variables initialize to false by default.
false. Boolean variables initialize to false by default.
← Didn't Know|Knew It →
What is the output of: System.out.println(7 / 2);?
What is the output of: System.out.println(7 / 2);?
Tap to reveal answer
- Integer division truncates decimal portion.
- Integer division truncates decimal portion.
← Didn't Know|Knew It →
What is garbage collection in Java?
What is garbage collection in Java?
Tap to reveal answer
Automatic memory management to reclaim memory used by unreachable objects. Prevents memory leaks by cleaning unused objects.
Automatic memory management to reclaim memory used by unreachable objects. Prevents memory leaks by cleaning unused objects.
← Didn't Know|Knew It →
Which Java keyword is used to create an object?
Which Java keyword is used to create an object?
Tap to reveal answer
new. Allocates memory for object creation.
new. Allocates memory for object creation.
← Didn't Know|Knew It →
What is the function of the 'this' keyword in Java?
What is the function of the 'this' keyword in Java?
Tap to reveal answer
Refers to the current instance of a class. Distinguishes instance variables from parameters.
Refers to the current instance of a class. Distinguishes instance variables from parameters.
← Didn't Know|Knew It →
What is the purpose of the 'static' keyword in Java?
What is the purpose of the 'static' keyword in Java?
Tap to reveal answer
To indicate that a field or method belongs to the class, not instances. Shared across all instances of the class.
To indicate that a field or method belongs to the class, not instances. Shared across all instances of the class.
← Didn't Know|Knew It →
Identify the statement that imports classes in Java.
Identify the statement that imports classes in Java.
Tap to reveal answer
import. Allows use of external classes and packages.
import. Allows use of external classes and packages.
← Didn't Know|Knew It →
Which access modifier makes a class member accessible only within its own class?
Which access modifier makes a class member accessible only within its own class?
Tap to reveal answer
private. Most restrictive access level available.
private. Most restrictive access level available.
← Didn't Know|Knew It →
What is polymorphism in programming?
What is polymorphism in programming?
Tap to reveal answer
Ability to process objects differently based on their data type or class. Same interface, different implementations possible.
Ability to process objects differently based on their data type or class. Same interface, different implementations possible.
← Didn't Know|Knew It →
Define 'inheritance' in programming.
Define 'inheritance' in programming.
Tap to reveal answer
A mechanism where a new class is derived from an existing class. Child class acquires parent class properties.
A mechanism where a new class is derived from an existing class. Child class acquires parent class properties.
← Didn't Know|Knew It →
What is encapsulation in object-oriented programming?
What is encapsulation in object-oriented programming?
Tap to reveal answer
Restricting access to the internal state of an object. Hides implementation details behind public interface.
Restricting access to the internal state of an object. Hides implementation details behind public interface.
← Didn't Know|Knew It →
What is an algorithm?
What is an algorithm?
Tap to reveal answer
A step-by-step procedure to solve a problem. Algorithms provide systematic approaches to problem-solving.
A step-by-step procedure to solve a problem. Algorithms provide systematic approaches to problem-solving.
← Didn't Know|Knew It →
State the function of the 'break' statement.
State the function of the 'break' statement.
Tap to reveal answer
To exit a loop or switch statement prematurely. Immediately exits current loop or switch block.
To exit a loop or switch statement prematurely. Immediately exits current loop or switch block.
← Didn't Know|Knew It →
What is the output of the expression $5 + 3 \times 2$?
What is the output of the expression $5 + 3 \times 2$?
Tap to reveal answer
- Multiplication has higher precedence than addition.
- Multiplication has higher precedence than addition.
← Didn't Know|Knew It →
What is the output of: System.out.println(7 / 2);?
What is the output of: System.out.println(7 / 2);?
Tap to reveal answer
- Integer division truncates decimal portion.
- Integer division truncates decimal portion.
← Didn't Know|Knew It →
What is the output of: System.out.println(2 + "3");?
What is the output of: System.out.println(2 + "3");?
Tap to reveal answer
- String concatenation occurs with + operator.
- String concatenation occurs with + operator.
← Didn't Know|Knew It →
What is the primary role of a linker?
What is the primary role of a linker?
Tap to reveal answer
To combine multiple object files into a single executable. Links compiled modules into one executable program.
To combine multiple object files into a single executable. Links compiled modules into one executable program.
← Didn't Know|Knew It →
Determine the result of $7 mod 3$.
Determine the result of $7 mod 3$.
Tap to reveal answer
- Modulo returns the remainder after division.
- Modulo returns the remainder after division.
← Didn't Know|Knew It →