Question 1 of 10
Which keyword in a method header identifies a class method?
- A. instance
- B. static
- C. classCall
- D. construct
Which keyword in a method header identifies a class method?
Class TramCar defines public static int seats(). Which call from a different class is correct?
Does calling an accessible class method normally require constructing an object first?
TramCar is documented below. What value does cap hold?
| Member | Kind | Contract |
|---|---|---|
| seats | class method | returns 24 |
| load | class method | returns 24 plus the given standing int |
int cap = TramCar.load(6);
TramCar.seats() returns 24. What value does mixed hold?
int mixed = TramCar.seats() - 4;
These methods are both in class TramCar. What value does TramCar.full() return?
public static int seats()
{
return 24;
}
public static int full()
{
return seats() + 8;
}
Class Depot does not define seats. TramCar defines public static int seats() returning 24. Which statement about this Depot code is true?
int n = seats();
TramCar.cars() returns 3 and TramCar.total(int n) returns n * 24. What value is displayed?
System.out.print(TramCar.total(TramCar.cars()));
TramCar.bell() is public static void and prints CLANG. What text is displayed?
System.out.print("GO");
TramCar.bell();
System.out.print("STOP");
TramCar.load(int standing) returns 24 + standing. What value is displayed?
int standing = 5;
TramCar.load(standing);
System.out.print(standing);