COP 2210 Final Review: Class Exams Flashcards
11 Questions
100 Views

COP 2210 Final Review: Class Exams Flashcards

Created by
@CorrectSaxhorn

Questions and Answers

What is the private instance variable for score 1 in Class Exams?

  • private int score2;
  • private int score1; (correct)
  • public int score2;
  • public int score1;
  • What is the constructor for Class Exams?

  • public Exams(String f)
  • public Exams(String fn, String ln)
  • public Exams() (correct)
  • public Exams(int score1, int score2)
  • What does the method void setScore1(int sc) do in Class Exams?

    Sets the value of score1 to sc.

    What does the method int getScore1() return in Class Exams?

    <p>Returns the value of score1.</p> Signup and view all the answers

    What is the return type of the method String toString() in Class Exams?

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

    What private instance variable is used in Class Student for the first name?

    <p>private String fName;</p> Signup and view all the answers

    What does the method double getAverage() return in Class Student?

    <p>The average of the exam scores.</p> Signup and view all the answers

    What does the method void remove() in Class ClassRoll do?

    <p>Removes a student based on their first and last name.</p> Signup and view all the answers

    What does the method void save() do in Class ClassRoll?

    <p>Saves the list of students back to the data file.</p> Signup and view all the answers

    What is declared in Class ClassRoll to hold student names?

    <p>private ArrayList students;</p> Signup and view all the answers

    What method prompts the user for a filename in Class Main?

    <p>public static void main(String[] args)</p> Signup and view all the answers

    Study Notes

    Class Exams

    • Contains private instance variables: int score1 and int score2.
    • Uses a no-parameter constructor for initializing class state.
    • Public methods include:
      • void setScore1(int sc): Updates score1.
      • void setScore2(int sc): Updates score2.
      • int getScore1(): Returns the value of score1.
      • int getScore2(): Returns the value of score2.
      • String toString(): Returns scores in formatted string.

    Class Student

    • Private instance variables include: String fName, String lName, and an instance of Exams examGrds.
    • Constructor Student(String fn, String ln) initializes fName, lName, and creates an Exams object.
    • Public methods consist of:
      • void setScore1(int sc): Delegates score setting for exam 1 to examGrds.
      • void setScore2(int sc): Delegates score setting for exam 2 to examGrds.
      • String toString(): Returns the formatted string containing name and exam scores.
      • double getAverage(): Calculates the average of exam scores.
      • int compareTo(Student s): Compares student names alphabetically and returns comparison results.

    Class ClassRoll

    • Private variables: ArrayList<Student> students, String title, and String fileName.
    • Constructor ClassRoll(String f) reads student data from a specified input file and initializes students in an ArrayList.
    • Public methods include:
      • void remove(): Prompts for student name and removes them from the list.
      • void display(): Outputs the course title and each student's records, including their average.
      • void add(): Adds a new student based on user input and prevents duplicates.
      • void changeScore1(): Changes the exam 1 score for a given student.
      • void changeScore2(): Changes the exam 2 score for a given student.
      • void find(): Displays the scores and average for a specified student.
      • void sortAverage(): Sorts students by their average score without using built-in sort methods.
      • void sortNames(): Sorts students by name in ascending order without using built-in sort methods.
      • void save(): Saves the updated list of students back to the input file.

    Class Main

    • Contains static methods:
      • void prompt(): Displays commands to the user.
      • void main(String[] args): Manages user input, file reading, and invokes corresponding methods for class roll management. It continues until the user enters q or quit.

    Studying That Suits You

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

    Quiz Team

    Description

    This quiz covers key concepts related to the Class Exams in COP 2210. It includes important definitions of instance variables, constructors, and public methods associated with the class. Use these flashcards to review and reinforce your understanding of the material.

    More Quizzes Like This

    Use Quizgecko on...
    Browser
    Browser