Program Design and Development - AP Computer Science Principles

  1. Identify the error: 'while(x > 0); { x--; }'
    Remove ';' after the condition. Semicolon creates empty loop body, preventing intended execution.
  2. Identify the error: 'if (x = 10)'
    Correct: 'if (x == 10)'. Single '=' assigns value; '==' compares for equality in conditions.
  3. What is the difference between a class and an object?
    Class is a blueprint; object is an instance. Template defines structure; instance contains actual data values.
  4. What does 'DRY' stand for in programming?
    Don't Repeat Yourself. Principle promoting code reusability by avoiding duplication.
  5. Which keyword is used to inherit a class in Java?
    extends. Establishes parent-child relationship between classes for code reuse.
  6. Which programming construct is used for decision making?
    Conditional statements. if-else and switch statements control program flow based on conditions.
  7. What is abstraction in programming?
    Hiding complex implementation details behind simple interfaces. Simplifies complexity by exposing only essential features to users.
  8. What is a function's return type?
    The data type of the value returned by the function. Specifies what kind of value the function sends back.
  9. Identify the error: 'int x = 10; float y = x / 0;'
    Division by zero error. Mathematical impossibility that causes runtime exception or undefined behavior.
  10. Find and correct the error: 'int[] arr = new int(5);'
    Correct: 'int[] arr = new int[5];'. Square brackets for arrays, not parentheses like method calls.
  11. What is an IDE?
    Integrated Development Environment. Software providing comprehensive tools for coding, debugging, and testing.
  12. Which method is the entry point for a Java application?
    main method. Starting point where JVM begins program execution.
  13. What is polymorphism in programming?
    Ability of different classes to respond to the same method call. Same interface produces different behaviors in different classes.
  14. Identify the error: 'switch(x) { case 1: x+=1; break; default: x-=1; }'
    No error. Proper switch syntax with break statements and default case.
  15. What is the difference between '==' and 'equals()' in Java?
    '==' checks reference equality; 'equals()' checks value equality. Reference vs content comparison for determining object equality.
  16. What is a software design pattern?
    A reusable solution to a common problem. Template providing proven structure for recurring design challenges.
  17. What is the role of an algorithm in program design?
    To outline the step-by-step solution to a problem. Provides clear, logical sequence of instructions to solve problems.
  18. What is the purpose of version control in software development?
    To manage changes to source code over time. Tracks modifications, enables collaboration, and maintains code history.
  19. What does 'MVC' stand for in software design?
    Model-View-Controller. Architectural pattern separating presentation, logic, and data concerns.
  20. What is the purpose of a loop in programming?
    To repeat a block of code multiple times. Automates repetitive tasks by controlling iteration and flow.
  21. Find and correct the error: 'for(int i = 0; i < 10; i+)'
    Correct: 'for(int i = 0; i < 10; i++)'. Missing second '+' in increment operator; should be 'i++'.
  22. What is inheritance in object-oriented programming?
    Mechanism for one class to inherit attributes and methods from another. Child classes acquire properties and behaviors from parent classes.
  23. Which loop executes at least once regardless of condition?
    Do-while loop. Condition checked after execution, guaranteeing minimum one iteration.
  24. Identify the error: 'if (x > y) x = 10; else; y = 10;'
    Remove ';' after else. Semicolon after else creates syntax error in conditional structure.
  25. Which data structure uses LIFO order?
    Stack. Last In, First Out - elements added/removed from same end.
  26. Find and correct the error: 'int x = "100";'
    Correct: 'int x = 100;'. String literal assigned to integer variable causes type mismatch.
  27. What is a syntax error?
    An error in the code's grammar or structure. Violates language rules preventing code from compiling or running.
  28. Which structure is used to handle exceptions in Java?
    try-catch block. Catches and manages runtime errors gracefully without crashing.
  29. What is encapsulation in object-oriented programming?
    Bundling data with methods that operate on the data. Data hiding principle combining related data and functions together.
  30. What is the function of a compiler?
    To convert source code into machine code. Translates high-level code into executable machine instructions.
  31. What is the purpose of a constructor in a class?
    To initialize new objects. Special method that sets up object state when created.
  32. What is a recursive function?
    A function that calls itself. Solves problems by breaking them into smaller identical subproblems.
  33. What is a variable's scope?
    The region of code where the variable is accessible. Determines where variables can be accessed within program structure.
  34. What is the difference between 'public' and 'private' access modifiers?
    'public' is accessible everywhere; 'private' is within the same class. Controls visibility and access levels for class members.
  35. What is an API?
    Application Programming Interface. Interface defining how software components communicate and interact.
  36. What is the primary purpose of program documentation?
    To explain code logic and facilitate future maintenance. Comments and structure make code understandable for others and future edits.
  37. Identify the first step in the program development life cycle.
    Problem analysis. Understanding requirements before designing solutions is essential first step.

Study these flashcards