Java Class Data Declaration Quiz

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

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++; } (D)</p> Signup and view all the answers

Flashcards are hidden until you start studying

More Like This

Java Class and Object Properties Quiz
5 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