Ask Question

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.

+4
Answers (1)
  1. 3 October, 10:23
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers