AP Computer Science a Flashcards: Introduction To Algorithms Programming And Compilers

Study Introduction To Algorithms Programming And Compilers 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.

AP Computer Science a

Introduction To Algorithms Programming And Compilers

0 mastered0 still learning

0% Complete

QUESTION
1/ 74

What is the main advantage of a 'for' loop over a 'while' loop?

Tap card or press Space to flip

ANSWER

It simplifies iteration with a counter. Built-in counter management reduces coding errors.

How well did you know it?

Card 1 / 74

What this deck covers

This deck focuses on Introduction To Algorithms Programming And Compilers, 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.

All flashcards

Flashcard 1: What is the main advantage of a 'for' loop over a 'while' loop?

Answer: It simplifies iteration with a counter. Built-in counter management reduces coding errors.

Flashcard 2: What is the output of: System.out.println(2 + "3");?

Answer:

  1. String concatenation occurs with + operator.

Flashcard 3: What is the output of: System.out.println(2 + "3");?

Answer:

  1. String concatenation occurs with + operator.

Flashcard 4: Identify the keyword used to define a class in Java.

Answer: class. Defines object blueprints in Java.

Flashcard 5: What is 'machine code'?

Answer: Binary code that a computer's CPU can execute directly. Consists of 1s and 0s that processors understand.

Flashcard 6: What is encapsulation in object-oriented programming?

Answer: Restricting access to the internal state of an object. Hides implementation details behind public interface.

Flashcard 7: What is a programming language?

Answer: A formal language used to write algorithms. It provides syntax and semantics for creating software.

Flashcard 8: What is recursion in programming?

Answer: A function calling itself to solve a subproblem. Breaks complex problems into smaller pieces.

Flashcard 9: What is garbage collection in Java?

Answer: Automatic memory management to reclaim memory used by unreachable objects. Prevents memory leaks by cleaning unused objects.

Flashcard 10: What is the return type of a method that does not return a value?

Answer: void. Indicates no value is returned to caller.

Flashcard 11: What is a 'null pointer exception'?

Answer: An error when accessing a method or field of a null object. Occurs when dereferencing null object references.

Flashcard 12: Identify the statement that imports classes in Java.

Answer: import. Allows use of external classes and packages.

Flashcard 13: Define 'inheritance' in programming.

Answer: A mechanism where a new class is derived from an existing class. Child class acquires parent class properties.

Flashcard 14: What is the base case in recursion?

Answer: The condition under which recursion stops. Prevents infinite recursion by terminating calls.

Flashcard 15: Which data structure is used for Last-In-First-Out (LIFO) access?

Answer: Stack. Items are added and removed from the top only.

Flashcard 16: What is polymorphism in programming?

Answer: Ability to process objects differently based on their data type or class. Same interface, different implementations possible.

Flashcard 17: What is recursion in programming?

Answer: A function calling itself to solve a subproblem. Breaks complex problems into smaller pieces.

Flashcard 18: Identify the method to find string length in Java.

Answer: length(). Returns character count in the string.

Flashcard 19: What is the default value of a boolean in Java?

Answer: false. Boolean variables initialize to false by default.

Flashcard 20: What is the return type of a method that does not return a value?

Answer: void. Indicates no value is returned to caller.

Flashcard 21: State the function of the 'break' statement.

Answer: To exit a loop or switch statement prematurely. Immediately exits current loop or switch block.

Flashcard 22: Define 'inheritance' in programming.

Answer: A mechanism where a new class is derived from an existing class. Child class acquires parent class properties.

Flashcard 23: Find the logical error in: if (x = 5) {...}

Answer: Use '==' for comparison, not '='. Assignment operator used instead of equality.

Flashcard 24: Find the logical error in: if (x = 5) {...}

Answer: Use '==' for comparison, not '='. Assignment operator used instead of equality.

Flashcard 25: What is the output of the expression 5+3×25 + 3 \times 2?

Answer:

  1. Multiplication has higher precedence than addition.

Flashcard 26: What is encapsulation in object-oriented programming?

Answer: Restricting access to the internal state of an object. Hides implementation details behind public interface.

Flashcard 27: Identify the statement that imports classes in Java.

Answer: import. Allows use of external classes and packages.

Flashcard 28: What is an algorithm?

Answer: A step-by-step procedure to solve a problem. Algorithms provide systematic approaches to problem-solving.

Flashcard 29: Define 'syntax error'.

Answer: An error in the source code that violates the grammar rules of the language. Detected during compilation before execution.

Flashcard 30: Identify the primary purpose of a compiler.

Answer: To translate source code into machine code. Compilers convert high-level code to executable format.

Flashcard 31: What is the primary role of a linker?

Answer: To combine multiple object files into a single executable. Links compiled modules into one executable program.

Flashcard 32: Which access modifier makes a class member accessible only within its own class?

Answer: private. Most restrictive access level available.

Flashcard 33: Identify the method to find string length in Java.

Answer: length(). Returns character count in the string.

Flashcard 34: What is the primary role of a linker?

Answer: To combine multiple object files into a single executable. Links compiled modules into one executable program.

Flashcard 35: What is a 'semantic error'?

Answer: An error where code executes without syntax errors but produces incorrect results. Logic error that runs but gives wrong output.

Flashcard 36: What is the time complexity of binary search?

Answer: O(log n)O(\text{log } n). Halves the search space with each comparison.

Flashcard 37: What is polymorphism in programming?

Answer: Ability to process objects differently based on their data type or class. Same interface, different implementations possible.

Flashcard 38: Define 'source code'.

Answer: Human-readable instructions written in a programming language. It's written by programmers before compilation.

Flashcard 39: Which data structure is used for Last-In-First-Out (LIFO) access?

Answer: Stack. Items are added and removed from the top only.

Flashcard 40: What is a programming language?

Answer: A formal language used to write algorithms. It provides syntax and semantics for creating software.

Flashcard 41: What is an algorithm?

Answer: A step-by-step procedure to solve a problem. Algorithms provide systematic approaches to problem-solving.

Flashcard 42: State the function of an interpreter.

Answer: To execute code line by line and translate it into machine language. Unlike compilers, interpreters process code at runtime.

Flashcard 43: What is an interface in Java?

Answer: A reference type that can contain only abstract methods. Cannot be instantiated, only implemented.

Flashcard 44: Identify the primary purpose of a compiler.

Answer: To translate source code into machine code. Compilers convert high-level code to executable format.

Flashcard 45: What is an interface in Java?

Answer: A reference type that can contain only abstract methods. Cannot be instantiated, only implemented.

Flashcard 46: What is the default value of a boolean in Java?

Answer: false. Boolean variables initialize to false by default.

Flashcard 47: Define 'source code'.

Answer: Human-readable instructions written in a programming language. It's written by programmers before compilation.

Flashcard 48: What is the purpose of the 'static' keyword in Java?

Answer: To indicate that a field or method belongs to the class, not instances. Shared across all instances of the class.

Flashcard 49: What is the output of: System.out.println(7 / 2);?

Answer:

  1. Integer division truncates decimal portion.

Flashcard 50: Identify the keyword used to define a class in Java.

Answer: class. Defines object blueprints in Java.

Flashcard 51: What is the purpose of the 'static' keyword in Java?

Answer: To indicate that a field or method belongs to the class, not instances. Shared across all instances of the class.

Flashcard 52: Define 'syntax error'.

Answer: An error in the source code that violates the grammar rules of the language. Detected during compilation before execution.

Flashcard 53: What is the time complexity of binary search?

Answer: O(log n)O(\text{log } n). Halves the search space with each comparison.

Flashcard 54: Determine the result of 7 mod 3.

Answer:

  1. Modulo returns the remainder after division.

Flashcard 55: What is the base case in recursion?

Answer: The condition under which recursion stops. Prevents infinite recursion by terminating calls.

Flashcard 56: Which loop continues executing as long as a condition is true?

Answer: while loop. Condition is checked before each iteration.

Flashcard 57: Which Java keyword is used to create an object?

Answer: new. Allocates memory for object creation.

Flashcard 58: What is garbage collection in Java?

Answer: Automatic memory management to reclaim memory used by unreachable objects. Prevents memory leaks by cleaning unused objects.

Flashcard 59: What is the function of the 'this' keyword in Java?

Answer: Refers to the current instance of a class. Distinguishes instance variables from parameters.

Flashcard 60: Which access modifier makes a class member accessible only within its own class?

Answer: private. Most restrictive access level available.

Flashcard 61: What is the result of: 'Hello'.charAt(1)?

Answer: e. Returns character at index 1 (second position).

Flashcard 62: What is the function of the 'this' keyword in Java?

Answer: Refers to the current instance of a class. Distinguishes instance variables from parameters.

Flashcard 63: State the function of an interpreter.

Answer: To execute code line by line and translate it into machine language. Unlike compilers, interpreters process code at runtime.

Flashcard 64: Determine the result of 7 mod 3.

Answer:

  1. Modulo returns the remainder after division.

Flashcard 65: What is a 'semantic error'?

Answer: An error where code executes without syntax errors but produces incorrect results. Logic error that runs but gives wrong output.

Flashcard 66: What is the main advantage of a 'for' loop over a 'while' loop?

Answer: It simplifies iteration with a counter. Built-in counter management reduces coding errors.

Flashcard 67: Which loop continues executing as long as a condition is true?

Answer: while loop. Condition is checked before each iteration.

Flashcard 68: Which Java keyword is used to create an object?

Answer: new. Allocates memory for object creation.

Flashcard 69: What is the output of: System.out.println(7 / 2);?

Answer:

  1. Integer division truncates decimal portion.

Flashcard 70: What is the output of the expression 5+3×25 + 3 \times 2?

Answer:

  1. Multiplication has higher precedence than addition.

Flashcard 71: What is 'machine code'?

Answer: Binary code that a computer's CPU can execute directly. Consists of 1s and 0s that processors understand.

Flashcard 72: What is a 'null pointer exception'?

Answer: An error when accessing a method or field of a null object. Occurs when dereferencing null object references.

Flashcard 73: What is the result of: 'Hello'.charAt(1)?

Answer: e. Returns character at index 1 (second position).

Flashcard 74: State the function of the 'break' statement.

Answer: To exit a loop or switch statement prematurely. Immediately exits current loop or switch block.