Java Software Engineer Question:
Tell us what are constructors in Java?
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
There are two types of constructors:
☛ Default constructor
☛ Parameterized constructor
Previous Question | Next 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? |