Ask Question
15 March, 09:37

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.

+4
Answers (1)
  1. 15 March, 09:56
    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?
Find 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 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