AP Computer Science Review Game

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Manefuto
M
Manefuto
Community Contributor
Quizzes Created: 1 | Total Attempts: 643
Questions: 39 | Attempts: 658

SettingsSettingsSettings
AP Computer Science Review Game - Quiz

Questions to help prepare for the midterm exam in AP Computer Science.


Questions and Answers
  • 1. 

    Which statement best describes a computer program? [Found in Quiz 1]

    • A.

      A program can only perform one simple task.

    • B.

      A program is a sequence of comments.

    • C.

      A program can decide what task it is to perform.

    • D.

      A program is a sequence of instructions and decisions that the computer carries out.

    Correct Answer
    D. A program is a sequence of instructions and decisions that the computer carries out.
    Explanation
    A computer program is a sequence of instructions and decisions that the computer carries out. This means that a program consists of a series of steps or commands that tell the computer what tasks to perform and how to perform them. It can include conditional statements that allow the program to make decisions based on certain conditions. This definition highlights the fact that a program is not limited to performing only one simple task, nor is it simply a sequence of comments. Instead, it encompasses a range of instructions and decisions that enable the computer to execute complex tasks.

    Rate this question:

  • 2. 

    What translates high-level descriptions into machine code? [Appears on Quiz 1]

    • A.

      Interpreter

    • B.

      Linker

    • C.

      Assembler

    • D.

      Compiler

    Correct Answer
    D. Compiler
    Explanation
    A compiler translates high-level descriptions, written in a programming language, into machine code. This process involves converting the entire code into a binary format that can be directly executed by the computer's processor. Unlike an interpreter, which translates and executes the code line by line, a compiler generates an executable file that can be run independently. Linkers, assemblers, and interpreters are also involved in the compilation process, but the compiler is responsible for the main translation of high-level code into machine code.

    Rate this question:

  • 3. 

    In Java, every statement must end with this symbol. [Appears on Quiz 1]

    • A.

      ;

    • B.

      )

    • C.

      -

    • D.

      !

    Correct Answer
    A. ;
    Explanation
    In Java, every statement must end with a semicolon (;). This is because the semicolon is used as a delimiter to mark the end of a statement. It is a crucial part of the Java syntax and is required to ensure that the code is properly structured and can be compiled without any errors.

    Rate this question:

  • 4. 

    What term is used to refer to a sequence of characters enclosed in quotation marks? [Appears on Quiz 1]

    • A.

      Comment

    • B.

      String

    • C.

      Method

    • D.

      Object

    Correct Answer
    B. String
    Explanation
    A sequence of characters enclosed in quotation marks is referred to as a string. Strings are commonly used to represent text in programming languages. They can include letters, numbers, symbols, and spaces. Strings are often used for storing and manipulating textual data in computer programs.

    Rate this question:

  • 5. 

    What is a term used to describe an error detected by the compiler that is a violation of the programming language rules? [Appears on Quiz 1]

    • A.

      Logic error

    • B.

      Typo

    • C.

      Syntax error

    • D.

      Run-time error

    Correct Answer
    C. Syntax error
    Explanation
    A syntax error is a term used to describe an error detected by the compiler that is a violation of the programming language rules. This means that the code written does not follow the proper syntax or grammar of the programming language being used. Syntax errors are typically caught by the compiler during the compilation process and need to be fixed before the code can be executed.

    Rate this question:

  • 6. 

    What term is used to refer to a sequence of steps for solving a problem that is unambiguous, executable, and terminating? [Appears on Quiz 1]

    • A.

      Documentation

    • B.

      Comments

    • C.

      Pseudoprogram

    • D.

      Algorithm

    Correct Answer
    D. Algorithm
    Explanation
    An algorithm is a term used to refer to a sequence of steps for solving a problem that is unambiguous, executable, and terminating. It is a well-defined and systematic approach to problem-solving, providing a clear set of instructions to achieve a specific outcome. Algorithms are commonly used in computer science and mathematics to solve complex problems efficiently and effectively. They play a crucial role in various fields, including programming, data analysis, and artificial intelligence.

    Rate this question:

  • 7. 

    Which statement about identifiers is correct? [Appears on Quiz 1]

    • A.

      Spaces are permitted inside identifiers.

    • B.

      Identifiers are not case sensitive.

    • C.

      Identifiers can be made up of letters, digits, and the underscore (_) character.

    • D.

      Identifiers can use symbols such as ? or %.

    Correct Answer
    C. Identifiers can be made up of letters, digits, and the underscore (_) character.
    Explanation
    This statement is correct because identifiers in programming languages can indeed be made up of letters, digits, and the underscore (_) character. This allows for a wide range of possibilities when naming variables, functions, or other elements in a program.

    Rate this question:

  • 8. 

    What is the result of a % b when variables a and b are declared as follows: int a = 9; int b = 5;? [Appears in Chap 2 & 4 HW3]

    • A.

      1.80

    • B.

      4

    • C.

      -80

    • D.

      1

    Correct Answer
    B. 4
    Explanation
    The result of a % b when a = 9 and b = 5 is 4. The % operator in programming is called the modulus operator, which returns the remainder of the division between two numbers. In this case, 9 divided by 5 equals 1 with a remainder of 4, so the result is 4.

    Rate this question:

  • 9. 

    What is the term that means to put strings together to form a longer string? [Appears in Chap 2 & 4 HW3]

    • A.

      Concatenation

    • B.

      Casting

    • C.

      Case

    • D.

      Adding

    Correct Answer
    A. Concatenation
    Explanation
    Concatenation refers to the process of combining or joining strings together to form a longer string. It involves taking two or more separate strings and merging them into a single string. This can be done using various programming languages and string manipulation techniques.

    Rate this question:

  • 10. 

    What is an object? [Appears in Quiz 2]

    • A.

      An entity in your program that is manipulated by calling methods.

    • B.

      A sequence of instructions.

    • C.

      Any input to a method.

    • D.

      Any value stored in a variable.

    Correct Answer
    A. An entity in your program that is manipulated by calling methods.
    Explanation
    An object is an entity in a program that can be manipulated by calling methods. In object-oriented programming, objects are instances of classes and they have their own set of properties and behaviors defined by the class. Objects allow for the organization and encapsulation of data and functionality, making it easier to manage and manipulate complex systems. By calling methods on an object, we can perform operations and modify its state. This definition accurately describes the concept of an object in programming.

    Rate this question:

  • 11. 

    Which of the following statements about methods is correct? [Appears in Quiz 2]

    • A.

      A method is a sequence of instructions that accesses the data of an object.

    • B.

      A method name is unique across the entire program.

    • C.

      A method can be called on any object in any class.

    • D.

      Methods are stored in variables.

    Correct Answer
    A. A method is a sequence of instructions that accesses the data of an object.
    Explanation
    A method is a sequence of instructions that accesses the data of an object. This means that a method is a set of code that performs a specific task or action on the data associated with an object. It allows us to manipulate and interact with the data within an object by performing operations or calculations. Methods are an essential part of object-oriented programming as they encapsulate the behavior or functionality of an object.

    Rate this question:

  • 12. 

    The input to a method is called a(n) _______________. [Appears in Quiz 2]

    • A.

      Parameter

    • B.

      Interface

    • C.

      Procedure

    • D.

      Overloaded

    Correct Answer
    A. Parameter
    Explanation
    In programming, a method is a block of code that performs a specific task. The input that is passed to a method is called a parameter. Parameters allow us to pass values or data into a method, which can then be used by the method to perform its task. They act as placeholders for the actual values that will be provided when the method is called. Therefore, the correct answer to the question is "parameter".

    Rate this question:

  • 13. 

    What is the type of an object? [Appears in Quiz 2]

    • A.

      Variable

    • B.

      Method

    • C.

      Reference

    • D.

      Class

    Correct Answer
    D. Class
    Explanation
    The correct answer is "class" because an object is an instance of a class. In object-oriented programming, a class is a blueprint for creating objects. Objects are created from classes and they have their own unique set of properties and behaviors defined by the class. Therefore, the type of an object is determined by its class.

    Rate this question:

  • 14. 

    The output of a method is called its __________ value. [Appears in Quiz 2]

    • A.

      Parameter

    • B.

      Return

    • C.

      Implicit

    • D.

      Explicit

    Correct Answer
    B. Return
    Explanation
    The output of a method is commonly referred to as its "return" value. This is because when a method is called, it performs a series of operations and then returns a value back to the caller. This value can be used for further processing or stored in a variable. The "return" keyword is used in the method to specify the value that should be returned.

    Rate this question:

  • 15. 

    A _____________ is a collection of classes with a related purpose. [Appears in Quiz 2]

    • A.

      Method

    • B.

      Collection

    • C.

      Package

    • D.

      Import

    Correct Answer
    C. Package
    Explanation
    A package is a collection of classes with a related purpose. In Java, packages are used to organize and group related classes together. They provide a way to manage the code and make it more modular and reusable. By placing related classes in the same package, it becomes easier to locate and use them in the code. Packages also help in avoiding naming conflicts by providing a unique namespace for classes.

    Rate this question:

  • 16. 

    What contains the instructions to initialize the instance variables of an object? [Appears in Chap 3 HW5]

    • A.

      Initializer

    • B.

      Access specifier

    • C.

      Type name

    • D.

      Constructor

    Correct Answer
    D. Constructor
    Explanation
    A constructor contains the instructions to initialize the instance variables of an object. It is a special method that is automatically called when an object is created. The constructor is responsible for setting the initial values of the object's instance variables, ensuring that the object is properly initialized and ready for use.

    Rate this question:

  • 17. 

    The name of the constructor is always the same as the name of the __. [Appears in Quiz 3]

    • A.

      Parameter variable

    • B.

      Access specifier

    • C.

      Class

    • D.

      Instance variable

    Correct Answer
    C. Class
    Explanation
    The name of the constructor is always the same as the name of the class. This is because the constructor is a special method that is used to initialize objects of a class. It is called automatically when an object is created, and it has the same name as the class it belongs to. This allows the constructor to be easily identified and called when creating new instances of the class.

    Rate this question:

  • 18. 

    A local variable is a variable declared in the... [Appears on Quiz 3]

    • A.

      Body of the class.

    • B.

      Header of a class.

    • C.

      Documentation comments.

    • D.

      Body of a method.

    Correct Answer
    D. Body of a method.
    Explanation
    A local variable is a variable that is declared within the body of a method. It is only accessible within the scope of that method and cannot be accessed by other methods or classes. Local variables are typically used to store temporary data or intermediate results within a method.

    Rate this question:

  • 19. 

    A method is invoked on what type of parameter? [Appears on Quiz 3]

    • A.

      Public parameter

    • B.

      Private parameter

    • C.

      Explicit parameter

    • D.

      Implicit parameter

    Correct Answer
    D. Implicit parameter
    Explanation
    When a method is invoked, the implicit parameter refers to the object on which the method is called. It is also known as the calling object or the target object. The implicit parameter is automatically passed to the method when it is called and allows the method to access the properties and behaviors of the object. In other words, the implicit parameter specifies the object that the method is being called on.

    Rate this question:

  • 20. 

    You should provide documentation comments for ___. [Appears on Quiz 3]

    • A.

      Only classes

    • B.

      Only methods with return values

    • C.

      Only methods with parameters

    • D.

      Every class, every method, every parameter, and every return value

    Correct Answer
    D. Every class, every method, every parameter, and every return value
    Explanation
    Documentation comments should be provided for every class, every method, every parameter, and every return value. This is important because documentation comments serve as a form of documentation for the code, providing information about the purpose, behavior, and usage of the classes, methods, parameters, and return values. This documentation can be helpful for other developers who may need to understand or use the code in the future, as well as for the original developer who may need to refer back to the code at a later time.

    Rate this question:

  • 21. 

    In the statement below, amount is referred to as the ____ parameter. public void deposit(double amount) [Appears on Quiz 3]

    • A.

      Private

    • B.

      Implicit

    • C.

      Public

    • D.

      Explicit

    Correct Answer
    D. Explicit
    Explanation
    In the given statement, the parameter "amount" is referred to as the explicit parameter because it is explicitly stated in the method signature.

    Rate this question:

  • 22. 

    A method header consists of these parts: __________________________ [Appears on Quiz 3]

    Correct Answer
    An access specifier, a return type, a method name, and a list of the parameters (if any).
    Explanation
    The method header consists of an access specifier, which determines the visibility of the method, a return type, which specifies the type of value that the method returns (if any), a method name, which is the identifier for the method, and a list of parameters (if any), which are the variables that the method accepts as input. These parts together define the signature of the method and allow other parts of the program to call and use the method correctly.

    Rate this question:

  • 23. 

    There are 3 items specified in when a method is called.  Provide the order of those three items: __________________ [Appeasr on Exam 1]

    Correct Answer
    object, method name, parameters
    Explanation
    The order of the three items specified when a method is called is as follows: first, the object on which the method is being called, then the name of the method itself, and finally any parameters that the method requires. This order is important because it allows the program to identify the specific object and method that need to be executed, and to pass any necessary data to the method through the parameters.

    Rate this question:

  • 24. 

    Which statement is true about a Java program? [Appeasr on Exam 1]

    • A.

      Java requires that at most one statement appear on one line.

    • B.

      Java forces the programmer to use a particular layout for readability.

    • C.

      Java is case sensitive.

    • D.

      The first method that is executed in a Java program is called Main.

    Correct Answer
    C. Java is case sensitive.
    Explanation
    Java is case sensitive, meaning that it distinguishes between uppercase and lowercase letters in its syntax. This means that when writing code in Java, the programmer must use the correct capitalization for keywords, variable names, and method names. For example, "System.out.println" is different from "system.out.println". This is an important aspect of the Java language and must be taken into consideration when writing and executing Java programs.

    Rate this question:

  • 25. 

    Which operator constructs object instances? [Appeasr on Exam 1]

    • A.

      Instanceof

    • B.

      Void

    • C.

      Construct

    • D.

      New

    Correct Answer
    D. New
    Explanation
    The "new" operator is used in Java to construct object instances. It is followed by the name of the class and parentheses, which can include arguments if necessary. When "new" is used, memory is allocated for the object and the constructor of the class is called to initialize the object. This allows us to create new instances of a class and use them in our program.

    Rate this question:

  • 26. 

    What is the output of the following program segment?    int num = 5;    while (num >= 0)    {          num -= 2;     }    System.out.print(num); [Not seen before]

    • A.

      -2

    • B.

      -1

    • C.

      0

    • D.

      2

    • E.

      21

    Correct Answer
    B. -1
    Explanation
    The program segment starts with the variable "num" initialized to 5. The while loop continues as long as "num" is greater than or equal to 0. Inside the loop, "num" is decremented by 2. Since 5 is greater than 0, the loop runs and "num" becomes 3. Then, "num" becomes 1, and finally -1. When the loop condition is checked again, -1 is not greater than or equal to 0, so the loop terminates. The final value of "num" is -1, which is printed as the output.

    Rate this question:

  • 27. 

    What is the output from                                int n = 12;       System.out.print(goFigure(n));       System.out.print(" " + n); where the method goFigure is defined as follows:            public double goFigure(int n)       {          n = n % 7;           return (double)(12 / n);        } [Not seen before]

    • A.

      2.4 12

    • B.

      2.4 6

    • C.

      2.4 5

    • D.

      2.0 12

    • E.

      2.0 5

    Correct Answer
    D. 2.0 12
    Explanation
    (double)(12 / 5) results in 2.0 [12 / 5.0 would allow for a result of 2,.4]
    and n remains unchanged because it is passed to goFigure by value and the scope changes which n variable it is looking at.

    Rate this question:

  • 28. 

    Which of the following statements displays 1234? I.    System.out.print(12 * 100 + 34); II.   System.out.print("12" + 34); III.  System.out.print(12 + "34"); [Not seen before]

    • A.

      None of the Above

    • B.

      I only

    • C.

      I and II only

    • D.

      II and III only

    • E.

      I, II, and III

    Correct Answer
    E. I, II, and III
  • 29. 

    In Java, what reserved word is used to identify constants? [unseen Wiley Chap 4 question]

    • A.

      Final

    • B.

      Int

    • C.

      Double

    • D.

      Constant

    Correct Answer
    A. Final
    Explanation
    The reserved word "final" is used in Java to identify constants. In Java, a constant is a variable whose value cannot be changed once it has been assigned. By using the "final" keyword, we can declare a variable as a constant, indicating that its value should remain constant throughout the program.

    Rate this question:

  • 30. 

    What is the term that means to explicitly convert a value to a different type? [unseen Wiley Chap 4 question]

    • A.

      Rounding

    • B.

      Cast

    • C.

      Case

    • D.

      Overflow

    Correct Answer
    B. Cast
    Explanation
    The term "cast" refers to explicitly converting a value to a different type. It is a process where a value of one data type is converted into another data type. This is often done when the programmer wants to perform operations or assignments that require different data types. By using the cast operator, the programmer can specify the desired data type for the value, allowing it to be converted accordingly.

    Rate this question:

  • 31. 

    Which of the following code fragments will compile without error? [unseen Wiley Chap 4 question]

    • A.

      (int) balance = 13.75;

    • B.

      Int balance = (double) 100;

    • C.

      Double balance = 13.75; int dollars = (int) balance;

    • D.

      Double balance = 13.75; int dollars = balance;

    Correct Answer
    C. Double balance = 13.75; int dollars = (int) balance;
    Explanation
    The code fragment "double balance = 13.75; int dollars = (int) balance;" will compile without error. This is because the variable "balance" is declared as a double and assigned the value 13.75, which is a valid double value. The value of "balance" is then cast to an int and assigned to the variable "dollars". This casting is allowed because it is an explicit cast from a larger data type (double) to a smaller data type (int).

    Rate this question:

  • 32. 

    You access array elements with an integer index, using the _____ operator.

    • A.

      Element

    • B.

      ()

    • C.

      Get

    • D.

      {}

    Correct Answer
    D. {}
    Explanation
    You access array elements with an integer index, using the get operator.

    Rate this question:

  • 33. 

    What type of loop is executed at least once?

    • A.

      For

    • B.

      Off-by-one

    • C.

      Do

    • D.

      While

    Correct Answer
    C. Do
    Explanation
    The do-while loop is executed at least once because the condition is checked at the end of the loop. This means that the code block within the loop will always be executed at least once before the condition is evaluated.

    Rate this question:

  • 34. 

    With a __________________ array, keep a companion variable to track how many elements are used.

    • A.

      Parallel

    • B.

      Uninitialized

    • C.

      Empty

    • D.

      Partially filled

    Correct Answer
    D. Partially filled
    Explanation
    In this context, the term "partially filled" suggests that the array contains some elements, but not all of its elements have been assigned a value. To keep track of the number of elements that have been used, a companion variable is used. This variable helps in determining the actual size or length of the array and allows for efficient memory allocation and manipulation.

    Rate this question:

  • 35. 

    Index values of an array list named qInfo range from ______ to ________.

    • A.

      1, qInfo.size

    • B.

      0, qInfo.size() - 1

    • C.

      0, qInfo.length - 1

    • D.

      1, qInfo.length()

    Correct Answer
    B. 0, qInfo.size() - 1
    Explanation
    The index values of an array list named qInfo range from 0 to qInfo.size() - 1. This is because the index of the first element in an array list is 0, and the index of the last element is the size of the array list minus 1. Therefore, the valid index values for qInfo would be 0, 1, 2, ..., qInfo.size() - 1.

    Rate this question:

  • 36. 

    1. Rewrite the following traditional for loop header as an enhanced for loop, assuming that  ArrayList<String> names has been initialized.
         for (int i = 0; i < names.size(); i++)    {       // process name    }

    • A.

      For (int i = 0; i < names.size(); i++)

    • B.

      For (s : names)

    • C.

      For (names : String s)

    • D.

      For (String s : names)

    Correct Answer
    D. For (String s : names)
    Explanation
    The correct answer is "for (String s : names)". In an enhanced for loop, the loop variable is declared as the type of the elements in the collection followed by a colon, and then the name of the collection. In this case, the loop variable is "String s" and the collection is "names", which is an ArrayList of Strings. This loop will iterate over each element in the names ArrayList and assign it to the variable "s", allowing for easy processing of each name.

    Rate this question:

  • 37. 

    Which method inserts an element in the middle of an array list, increasing its size?

    • A.

      Set operator

    • B.

      New operator

    • C.

      Insert method

    • D.

      Add method

    Correct Answer
    D. Add method
    Explanation
    The add method is used to insert an element in the middle of an array list and it also increases the size of the array list. This method allows you to specify the index at which you want to insert the element, and it will shift the existing elements to accommodate the new element. By using the add method, you can effectively insert an element in the middle of the array list and ensure that the size of the list is appropriately increased.

    Rate this question:

  • 38. 

    When the body of a loop contains another loop, the loops are __________.

    • A.

      Symmetric

    • B.

      Nested

    • C.

      Spaghetti code

    • D.

      Asymmetric

    Correct Answer
    B. Nested
    Explanation
    When the body of a loop contains another loop, the loops are referred to as "nested." This means that one loop is enclosed within another loop, creating a hierarchical structure. The outer loop controls the execution of the inner loop, and the inner loop is executed multiple times for each iteration of the outer loop. This nesting allows for more complex and intricate control flow in programming, as different levels of loops can be used to handle different tasks or conditions.

    Rate this question:

  • 39. 

    Which statement accesses the first element of an array of strings named sData.

    • A.

      String s = sData(0);

    • B.

      String s = sData[0];

    • C.

      String s = sData.get(0);

    • D.

      String s = sData[1];

    Correct Answer
    B. String s = sData[0];
    Explanation
    The correct answer is "String s = sData[0];". This statement uses square brackets to access the first element of the array named sData. The index inside the square brackets is 0, which represents the first element in the array.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • May 08, 2019
    Quiz Created by
    Manefuto
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.