Ask Question
12 July, 03:56

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.

+5
Answers (1)
  1. 12 July, 05:08
    0
    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); }

    }

    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 "-".
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write the definition of a class Telephone. The class has no constructors, one instance variable of type String called number, and two ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers