Java Class Data Declaration Quiz

GentleBallad avatar
GentleBallad
·
·
Download

Start Quiz

Study Flashcards

4 Questions

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;

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

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

Which code segment correctly counts the number of odd values in an integer array 'nums' and stores the count in 'oddCount'?

int oddCount = 0; for (int i = 0; i < nums.length; i++) { if (nums[i] % 2 != 0) oddCount++; }

Test your knowledge on declaring data in a Java class for a Bowler. Choose the best way to store the bowler's high score, average score, and last 10 scores. Select the correct syntax for the data declaration in the Bowler class.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Java Class and Object Properties Quiz
5 questions
Java Stack Class Quiz
10 questions
Introduction to Java Scanner Class
18 questions
Java String Class and Operations Quiz
18 questions
Use Quizgecko on...
Browser
Browser