OOPs

21. Create a class showing an example of parameterized constructor.

            class My{
                My(int x){
                    System.out.println("This is Parametrized Constructor. x = " + x);
                }
            }
            
            class Main{
                public static void main(String[] args){
                    new My(500);
                }
            }
        

OUTPUT

            This is Parametrized Constructor. x = 500