#2 Test questions help

5 messages · Page 1 of 1 (latest)

crystal fern
#

Hi, I have 2 questions on my 25 question test I am not too sure about. If someone wants to help me answer them and explain the answers, that would be great. I could probably go to chatgpt, but I actually want to learn. The questions are below, and thank you!

An array starts with a series of numeric values and finishes with a different set of numeric values after a method is called that balances the degree of a certain chemical.

public static void balancer(int[] chemRatios) {
    if (chemRatios[0] % 3 == 0) {
        chemRatios[0] += 2;
    }

    if (chemRatios[3] > 48) {
        chemRatios[4] = 5;
    }
    if (chemRatios[5] > chemRatios[6]) {
        chemRatios[7] -= 2;
    }
}

The runner code in the client application sets up the array of chemical values as

 int[] chemVals = /* mystery assignment */

then, the method is called,

    balancer(chemVals);

The array should end up as { 47, 34, 23, 55, 5, 12, -1, 2 }

What is the mystery assignment?
Group of answer choices

A) int[] chemVals = {33, 34, 23, 2, 77, 12, -11, 14};

B) int[] chemVals = {45, 34, 23, 15, 71, 12, -1, 2};

C) int[] chemVals = {45, 34, 23, 55, 77, 12, -1, 4};

D) int[] chemVals = {45, 34, 13, 54, 77, 12, -1, 4};

Given the code below, what can you state? Pick 3. You can assume that the code is accurate and functional, and methods getAge and setAge are appropriate methods for class SoccerPlayer.

    SoccerPlayer[] team = setupTeam();
    for (SoccerPlayer player : team)
        player.setAge(player.getAge() + 1);

Group of answer choices

A) an array of SoccerPlayer objects is returned from method or function setUpTeam.

B) the first element is not accessed and therefore left unchanged

C) the last element of the array is not accessed, and therefore left unchanged

D) The array is composed of primitives

E) team is an array of SoccerPlayer objects

F) each element of the array has an attribute value change

outer hillBOT
#

This post has been reserved for your question.

Hey @crystal fern! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

spark schooner
#

What part of question 1 stumps you? What part of question 2 stumps you?