Can we have parameterized constructors in Java?

Can we have parameterized constructors in Java?

Yes, we can have.
This is also called as constructor overloading.
Example:
Class clsEmp
{
        int age;
        clsEmp()
        {
           age = 21;
        }
        clsEmp(int a)
        {
           age = a;
        }
}
JSP Interview Questions and Answers - Freshers & Experienced!
JSP interview questions with answers for freshers and experienced, JSP interview FAQ - In this series, we have covered all about JSP and answered the questions that might be asked during an interview.
What is JSP?
What is JSP? - JavaServerPages is server side component in a web application, used to dynamically generate HTML / XML documents...
Categories of JSP tags - Directives, Scripting elements, Actions
"Categories of JSP tags - Directives: The directive tags are used for simple java programming calls like importing packages, specifying the error handling pages or to handle session in a JSP page...
Post your comment