Computer Programming Exam: Multiple Choice Quiz

15 Questions | Total Attempts: 4180

SettingsSettingsSettings
Please wait...
Computer Programming Exam: Multiple Choice Quiz

Trivia: introduction to computer programming! Different software enable a computer to achieve specific tasks and using different programming languages, one is able to come up with a desired software. Using the quiz questions below you will get a chance to review some basic information you have on programming as a whole and different types of data one can use. Try it out and get to refresh your memory. All the best!.


Questions and Answers
  • 1. 
    During program development, software requirements specify
    • A. 

      How the program will accomplish the task

    • B. 

      What the task is that the program must perform

    • C. 

      How to divide the task into subtasks

    • D. 

      How to test the program when it is done

  • 2. 
    Of the following, if statements, which one correctly executes three instructions if the condition is true?
    • A. 

      If (x < 0) a = b * 2; y = x; z = a – y;

    • B. 

      { if (x < 0) a = b * 2; y = x; z = a – y; }

    • C. 

      If{ (x < 0) a = b * 2; y = x; z = a – y ; }

    • D. 

      If (x < 0) { a = b * 2; y = x; z = a – y; }

  • 3. 
    • A. 

      If (x > 0) x++; else x--;

    • B. 

      If (x > 0) x++; else if (x < 0) x--;

    • C. 

      If (x == 0) x = 0; else x++; x--;

    • D. 

      X++; x--;

  • 4. 
    Kyle is working on a loop that will execute several lines of code multiple times within a program. Each time the code executes the program should prompt the user to enter in a test grade. He is debating between the following two program statement setups A. for (int index = 0; grade < index; index++) System.out.print (“Please enter another grade); grade= keyboard.readDouble(); B. for (int index = 0; grade < index; index++) { System.out.print (“Please enter another grade); grade= keyboard.readDouble(); } Which statement below best outlines the choice (A or B) Kyle should make concerning his code.
    • A. 

      The code within section A or B would allow the person to enter the grade multiple times

    • B. 

      The code within section A would be the best selection because the {} brackets indicate a decision must be made within a program.

    • C. 

      The for loop is structured incorrectly in both A and B meaning Kyle should rewrite the code statement.

    • D. 

      The code within section B is the best selection because the {} brackets allow both lines of code to be executed each time the loop occurs.

  • 5. 
    Jim currently runs a car rental dealership and wishes to write a program that allows the user to enter the temperature of the location they plan to visit and then recommend a car based on the data.  Below is a summary of the program structure Jim is looking for.         Temp greater than 80 a Convertible should be selected.         Temp  greater than 60 and less than 80 an SUV should be selected         Temp less than 60 a truck should be selected.   Jim has no trouble writing the code if the temperate is greater than 80 but gets stuck when he arrives at the second line of code which reads Temp greater than 60 and less than 80 an SUV should be selected.  What type of operator is Jim needing to use within his code?
    • A. 

      &&

    • B. 

      | |

    • C. 

      !=

    • D. 

      ==

  • 6. 
    _______ is the process of finding errors and fixing them within a program.
    • A. 

      Compiling

    • B. 

      Executing

    • C. 

      Debugging

    • D. 

      Scanning

  • 7. 
    Compare the following two if statements and select, which answer best, summarizes each line of code.         string name1, name2; int guess, answer;   if (name1.equals(name2))         if (guess == answer)
    • A. 

      The first if statement will compare the numerical value of the two names entered to see if they are equal and the second if statement will also compare the numerical values to see if they are equal

    • B. 

      The first if statement will not work correctly due to string values being used, the second if statement will correctly compare the variables guess and answer

    • C. 

      The first if statement will compare the two string values to see if they are equal and the second will compare the two integer values to see if they are equal.

    • D. 

      The first if statement should read if (name1 == name2) in order to properly compare the values and the second if statement will compare the numerical values to see if they are equal.

  • 8. 
    Sal needs to execute a section of code ten times within a program. Compare the selection structures below and select which one meets the needs identified.
    • A. 

      If-Else

    • B. 

      For

    • C. 

      While

    • D. 

      If

  • 9. 
    Kendra has implemented a While loop within her Java program. Assess the code statement below and select which answer best summarizes the output Kendra will experience once the while statement is executed. int count = 1; while (count <=25) { System.out.println (count); Count = count –1; } System.out.println (“Done”);
    • A. 

      The while loop will execute 25 times and print the numbers 1 thru 25 and finish with the printing of Done.

    • B. 

      The while loop will execute 25 times and print the numbers 25 down to 1 and finish with the printing of Done

    • C. 

      The while statement will not function correctly due to a missing semicolon(;) after the statement while (count

    • D. 

      The while statement will execute by counting down from 1 until infinity and result in an infinite loop

  • 10. 
    A loop that never ends is referred to as a(n)_________.
    • A. 

      While loop

    • B. 

      Infinite loop

    • C. 

      Recursive loop

    • D. 

      ) for loop

  • 11. 
    Kim has just constructed her first for loop within the Java language.  Which of the following is not a required part of a for loop?
    • A. 

      Initialization

    • B. 

      Condition

    • C. 

      Variable

    • D. 

      ) increment

  • 12. 
    Jay is considering adding a repetition statement within his Java programming final project. Jay is unsure of the number of times each loop needs to execute.  Analyze the conditional statements below and select which statement best fits the need identified by Jay within his programming.
    • A. 

      While loop

    • B. 

      If-Else

    • C. 

      For loop

    • D. 

      Switch statement

  • 13. 
    Which command will stop an infinite loop?
    • A. 

      Alt - C

    • B. 

      Shift - C

    • C. 

      Esc

    • D. 

      Ctrl - C

  • 14. 
    Score =Keyboard.readInt(); while (score !=  -1)         { System.out.println (“The score is” + score); score =Keyboard.readInt();         } USER INPUT = -1, predict what will happen after the user input is accepted into the java program.
    • A. 

      The while statement will continue to ask the user to enter a score and then print out the score that has been received.

    • B. 

      The while loop will execute an infinite number of times because the program statement can never be false

    • C. 

      The while statement will never print the statement “The score is” because the condition present within the while will be false on the first time through.

    • D. 

      The while statement will function until a value other than –1 is entered

  • 15. 
    Analyze the following error that was received when Scott tried to compile his java program named average. Average.java:14: 'else' without 'if' else ^ Which of the following could have resulted in the error being generated?
    • A. 

      Scott used an infinite loop within his program

    • B. 

      Scott placed a semicolon at the end of an If statement

    • C. 

      Scott used an incorrect looping structure

    • D. 

      Scott omitted a line of code below the If statement such as a System.out.pritnln or a Keybaord.readInt();