Calling Class Methods FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

Question 1 of 5

Class RadioTower declares public static int watts() which returns 50.

(a) Write a class-qualified call from another class that stores the result in int power. (b) Explain what the method is associated with. (c) Explain whether a RadioTower object must be constructed first.

Question 2 of 5

Both methods below are in class SignalDesk.

public static int base()
{
    return 18;
}
public static int span()
{
    return base() + 4;
}

(a) What value does SignalDesk.span() return? (b) Why is the call written as base() rather than SignalDesk.base() inside span? (c) Write the class-qualified call a different class would use to obtain that span.

Question 3 of 5

RadioTower.boost(int extra) returns 50 + extra.

(a) Trace int n = RadioTower.boost(6); and state the value of n. (b) Explain how the returned result is used. (c) Explain what would happen if the call were written as RadioTower.boost(6); with no assignment and then System.out.print(n); using an uninitialized n.

Question 4 of 5

Class Antenna contains only main. RadioTower defines public static void log() which prints TX, and public static int watts() which returns 50.

(a) Write a statement in Antenna that calls log correctly. (b) Write a statement in Antenna that prints the watts result. (c) Explain why watts() with no class name is not a legal call in Antenna.

Question 5 of 5

A classmate says static means arguments are not copied.

public class RadioTower
{
    public static int bump(int extra)
    {
        extra = extra + 3;
        return extra;
    }
}

int gain = 10;
RadioTower.bump(gain);
System.out.print(gain);

(a) State the displayed value. (b) Correct the classmate's claim. (c) Show one change that would make the displayed value 13.