Ask Question
2 June, 02:14

Write the definition of a class Telephone. The class has no constructors and one static method printNumber. The method accepts a String argument and prints it on the screen. The method returns nothing.

+1
Answers (1)
  1. 2 June, 04:12
    0
    The program to this question can be given as:

    Program:

    public class Telephone / /define class Telephone.

    {

    public static void printNumber (String s) / /define method

    {

    System. out. print (s); / /print value.

    }

    public static void main (String[] args) / /define main method

    {

    String s = "ABCD"; / /define variable s and assign value.

    printNumber (s); / /calling function.

    }

    }

    Output:

    ABCD

    Explanation:

    In above java program we define a class that is "Telephone". Inside the class we define a function that is "printNumber" in the function we pass one string value that is "s" and the function will not return any value, because we use return type void. In this function we print pass variable value.

    Then we define the main method inside the method we define a string variable and assign a value that is s = "ABCD" and call the function that prints its value.
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 and one static method printNumber. The method accepts a String ...” 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