Scala program to implement method overloading based on a different order of arguments
belongs to collection: Scala Classes & Objects Programs
All Answers
total answers (1)
belongs to collection: Scala Classes & Objects Programs
total answers (1)
Program/Source Code:
The source code to implement method overloading based on a different order of arguments is given below. The given program is compiled and executed on the ubuntu 18.04 operating system successfully.
Output:
Explanation:
In the above program, we used an object-oriented approach to create the program. And, we created an object Sample.
Here, we created a class Calc. In the Calc class, we implemented method overloading by creating two PrintChar() methods with different order of arguments. The PrintChar() method is used to print the specified character on the console screen.
In the main() function, we created an object of the Calc class and called both methods with arguments, and printed the result on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer