Calling Class Methods MCQ Practice

Question 1 of 10

What is a class method associated with?

  1. A. One particular object that must already exist
  2. B. The class itself, not an individual instance
  3. C. Only the Scanner keyboard object
  4. D. Only a local variable inside main

Question 2 of 10

Class RadioTower defines public static int watts(). Which call is the usual class-qualified form from another class?

  1. A. watts.RadioTower()
  2. B. RadioTower watts
  3. C. RadioTower.watts()
  4. D. new RadioTower.watts

Question 3 of 10

When may the class name be omitted in a call to an accessible class method at this topic level?

  1. A. Never, in any Java file
  2. B. Whenever the method returns void
  3. C. When the call is written inside the class that defines the method
  4. D. Only if the method name has five letters

Question 4 of 10

RadioTower is documented below. What value does power hold after this code runs?

Member Kind Contract
watts class method returns 50
boost class method returns 50 plus the given int
int power = RadioTower.watts();
  1. A. 0
  2. B. 50
  3. C. 100
  4. D. The code cannot compile because no RadioTower object was constructed.

Question 5 of 10

Using the same RadioTower contract (watts returns 50; boost(int extra) returns 50 + extra), what value is displayed?

System.out.print(RadioTower.boost(8));
  1. A. 50
  2. B. 8
  3. C. 58
  4. D. 0

Question 6 of 10

RadioTower.watts() returns 50. What value does total hold?

int total = RadioTower.watts() + 12;
  1. A. 12
  2. B. 50
  3. C. 62
  4. D. 5012

Question 7 of 10

These methods are both in class RadioTower. What value does RadioTower.report() return?

public static int watts()
{
    return 50;
}
public static int report()
{
    return watts() + 5;
}
  1. A. 50
  2. B. 5
  3. C. 55
  4. D. The code cannot compile because watts needs RadioTower.watts().

Question 8 of 10

Class Antenna does not define watts. RadioTower defines public static int watts() returning 50. Which statement about this code in Antenna is true?

int n = watts();
  1. A. It stores 50.
  2. B. It stores 0.
  3. C. It does not compile; Antenna must use RadioTower.watts().
  4. D. It constructs a RadioTower automatically.

Question 9 of 10

RadioTower.band() returns 2 and RadioTower.offset(int n) returns n + 7. What value is displayed?

System.out.print(RadioTower.offset(RadioTower.band()));
  1. A. 2
  2. B. 7
  3. C. 9
  4. D. 27

Question 10 of 10

RadioTower.log() is a public static void method that prints TX. What text does this code display?

System.out.print("ON");
RadioTower.log();
System.out.print("OFF");
  1. A. TX
  2. B. ONOFF
  3. C. ONTXOFF
  4. D. ONTX