195k views
4 votes
Write the definition of a class Telephone. The class has no constructors and one static method getFullNumber. The method accepts a String argument and returns it, adding 718- to the beginning of the argument.

1 Answer

3 votes

Answer:

public class Telephone {

public static String getFullNumber(String a) {

return ("718-" + a);

}

}

In the explanation section we show the method in use with some displayed output

Step-by-step explanation:

The code to create an object of the class and use its method getFullNumber(String a) is given below:

public class TestClass {

public static void main(String[] args) {

Telephone TelephoneOne = new Telephone();

String newNumber=TelephoneOne.getFullNumber("080657288");

System.out.println(newNumber);

}

}

Write the definition of a class Telephone. The class has no constructors and one static-example-1
User SerjG
by
4.5k points