Java Software Engineer Question:

Tell us what are constructors in Java?

Tweet Share WhatsApp

Answer:

In Java, constructor refers to a block of code which is used to initialize an object. It must have the same name as that of the class. Also, it has no return type and it is automatically called when an object is created.

There are two types of constructors:

☛ Default constructor
☛ Parameterized constructor

Download Java Software Engineer PDF Read All 45 Java Software Engineer Questions
Previous QuestionNext Question
Tell us how can you swap the values of two numeric variables without using any other variables?Can you explain me what is Polymorphism?