Shreyas arya

Generation

generate functionFri, 10 Feb 2023

Create a method print a string If type is not string then throw exceptionand retry 3 times

// Java program to illustrate the // concept of method overloading class Test { // Method with 1 parameter public void disp(char c) { System.out.println(c); } // Method with 2 parameters public void disp(char c, int num) { System.out.println(c + " "+num); } } public class Main { public static void main(String args[]) { Test obj = new Test(); obj.disp('a'); obj.disp('a',10); } }

Questions about programming?Chat with your personal AI assistant