1.6k views
3 votes
Write the definition of a class Telephone. The class has no constructors, one instance variable of type String called number, and two static variables. One is of type int called quantity; the other is of type double called total. Besides that, the class has one static method makeFullNumber. The method accepts two arguments, a String containing a telephone number and an int containing an area code.

1 Answer

3 votes

Answer:

public class Telephone

{

private String number;

private static int quantity;

private static double total;

public static String makeFullNumber(String phoneNum, int areaCode)

{ return(areaCode + "-" + phoneNum); }

}

Step-by-step explanation:

The class name is Telephone.

It has one instance variable named number.

It contains two static variables. static variables belongs to the class Telephone and these are initialized only once and shared among all of Telephone class objects.

The static variable quantity is of data type int which accepts integer values.

The static variable total is of data type double which accepts real values.

The class has static method makeFullNumber. This method has two parameters phoneNum and areaCode. The function returns the area code followed by telephone number and they both are separated by dash "-".

User Zkanoca
by
4.4k points