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. The method concatenates the two arguments in the following manner: First comes the area code, then a dash, then the telephone number. The method returns the resultant string.

LANGUAGE: JAVA

CHALLENGE:

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. The method concatenates the two arguments in the following manner: First comes the area code, then a dash, then the telephone number. The method returns the resultant string.

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,

4 Comments

  1. jas on March 27, 2016 at 9:46 am

    correct answer

    public class Telephone
    {
    private String number;
    private static int quantity;
    }

    • Anonymous Goat on November 13, 2016 at 8:28 pm

      public class Telephone
      {
      private String number;
      private static int quantity;
      private static double total;
      public static String makeFullNumber(String telephone, int area)
      {
      return(area + “-” + telephone);
      }
      }

  2. jps123 on May 8, 2017 at 10:00 pm

    This is correct Answer
    public class Telephone
    {
    private String number;
    private static int quantity;
    private static double total;
    public static String makeFullNumber(String telephone, int area)
    {
    return (area + “-” + telephone);
    }
    }

  3. shusma kafle on November 23, 2017 at 8:07 pm

    public class Telephone {

    private String number;
    private static int quantity;
    private static double total;

    public static String makeFullNumber(String phoneNumber, int areaCode) {
    return String.valueOf(areaCode) + “-” + phoneNumber;
    }
    }

Leave a Comment

You must be logged in to post a comment.