Java Class Data Declaration Quiz
4 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 most appropriate way to declare the data for a Bowler class including high score, average score, and last 10 scores?

  • private int highScore; private double avgScore; private int[] scores; (correct)
  • private int highScores, scores; private double avgScore;
  • private int highScores; private int[] scores; private double avgScore;
  • private int[] scores; private int highScores, avgScore;
  • What will be printed as a result of executing the code segment: int[] myArray = { 2, 5, 4, -16, -4 }; myArray = myArray ; myArray = myArray ; System.out.println(myArray * (-2)) ;

  • 0 (correct)
  • 18
  • 8
  • 32
  • What will be printed as a result of executing the code segment: int[] q = {4, 2, 12, 13, -5}; System.out.println(q.length + q);

  • 15 (correct)
  • 17
  • 18
  • 16
  • Which code segment correctly counts the number of odd values in an integer array 'nums' and stores the count in 'oddCount'?

    <p>int oddCount = 0; for (int i = 0; i &lt; nums.length; i++) { if (nums[i] % 2 != 0) oddCount++; }</p> Signup and view all the answers

    More Like This

    Java Class Dependency Graph Quiz
    9 questions
    Java Stack Class Quiz
    10 questions
    Using Scanner Methods to Read Data
    18 questions
    Java User Input Basics Quiz
    29 questions

    Java User Input Basics Quiz

    OrganizedCombinatorics3127 avatar
    OrganizedCombinatorics3127
    Use Quizgecko on...
    Browser
    Browser