Exam 2 Review - COMP 1000
16 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the maximum size of notes allowed during the exam?

  • 8.5x14 inches
  • 8.5x11 inches (correct)
  • 5x7 inches
  • A3 size
  • Which of the following programming constructs is used for repeated execution of a block of code in Java?

  • switch-case statement
  • getter method
  • for loop (correct)
  • if statement
  • In Java, which operator is used for integer division?

  • //
  • / (correct)
  • :
  • %
  • Which statement correctly represents the use of a try-catch block in Java?

    <p>try-catch blocks can handle exceptions without stopping the program.</p> Signup and view all the answers

    What will be the output of the following code if the user enters 5, 3, and 0 in sequence: 'Scanner input = new Scanner(System.in);int number;int max = 0;while ((number = input.nextInt()) > 0) { if (number > max) { max = number; }} System.out.println(max);'?

    <p>5</p> Signup and view all the answers

    Which of the following is a valid way to declare an ArrayList in Java?

    <p>ArrayList<type> list = new ArrayList<type>();</p> Signup and view all the answers

    What is the purpose of Javadoc in Java programming?

    <p>To generate API documentation from comments in the code.</p> Signup and view all the answers

    Which of the following statements about flowcharts is accurate?

    <p>Flowcharts help visualize the sequence of operations in a program.</p> Signup and view all the answers

    What will happen if the user enters a negative number when prompted for positive integers?

    <p>The program will print the highest number entered so far.</p> Signup and view all the answers

    What is the initial value of 'max' used for in the scanner input program?

    <p>0</p> Signup and view all the answers

    In the factorial program, what happens if the user inputs a negative integer?

    <p>The program will output an error message and terminate.</p> Signup and view all the answers

    Which of the following correctly represents the calculation of factorial in the provided program?

    <p>factorial = factorial * i</p> Signup and view all the answers

    What is the function of the loop in the factorial program?

    <p>To compute the product of numbers from 1 to N.</p> Signup and view all the answers

    Why should the program check if 'max' is equal to 0 after the loop?

    <p>To confirm whether any numbers were entered at all.</p> Signup and view all the answers

    If the user inputs N=5 for the factorial program, what is the expected output when the program runs?

    <p>120</p> Signup and view all the answers

    What type of loop is suggested for printing a square of characters in the 'squarePattern' method?

    <p>For loop</p> Signup and view all the answers

    Study Notes

    Exam 2 Review - COMP 1000

    • Format:

      • Exam II is similar to Exam I.
      • Students get one 8.5x11" sheet of paper for notes.
      • Notes can be written on both sides.
      • No calculators, books, laptops, phones, headsets, smartwatches allowed, only the single page of notes.
      • Exam will include multiple-choice/multiple select/true/false, explaining programs/parts, translating math to Java, writing and debugging code, fill-in-the-blank, and short answer questions.
    • Content:

      • Input and output (Scanner and Print)
      • Exceptions, try-catch, try-with-resources, hasNext()
      • Mathematical expressions in Java (order of operations, integer division, etc.)
      • if-else, switch-case statements
      • while, do-while, and for loops
      • Flowcharts and Control flow
      • Methods and scope
      • Javadoc, git, eclipse, general computing concepts
      • Arrays and ArrayLists
      • Reading Files with Scanner (first part of File I/O)
    • Review Exercises:

      • Exercises may not be the same format as the exam.
      • Provided practice exercises to help with question style, and complexity.
      • Exam 1 review or previous exam slides also helpful.
    • Example Exercises and Answers:

      • A program reading positive integers and printing the highest.
      • A program to calculate N! (factorial)
      • A method to calculate gravitational force between two bodies.
        • Use formula F = Gm1m2/d2
        • G = 6.673 x 10^-11
        • Pass mass (m1, m2) and distance (d) as arguments.
      • Program to read 10 integers and print in reverse order using an array.
    • Additional Problems:

      • Additional exercises are available for further study.
      • Implement the questions from the Day of the specific class.
    • Additional Information:

      • Students need to review all covered material for the semester.
      • To prepare for an exam, go through the provided examples and exercises.
      • Review the notes, and the provided programming examples.
      • Additional help is available during or after the class.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    Description

    Prepare for your Exam II in COMP 1000 with this comprehensive review covering essential concepts such as input/output, control flow, methods, and data structures in Java. The exam format includes various types of questions that will test your understanding of the material. Use this quiz to assess your knowledge and strengthen your skills before the test.

    More Like This

    Java Programming Basics Quiz
    5 questions
    Java Class and Object Fundamentals
    24 questions
    CSCE 111 Final Flashcards
    14 questions

    CSCE 111 Final Flashcards

    RapturousSunflower avatar
    RapturousSunflower
    Use Quizgecko on...
    Browser
    Browser