---
title: "What is the difference between constructor and method?"  
description: "What is the difference between constructor and method?"  
author: "Pushpendra Singh"  
published: 2010-10-25  
updated: 2020-09-18  
canonical: https://www.mindstick.com/interview/163/what-is-the-difference-between-constructor-and-method  
category: "java"  
tags: ["java"]  
reading_time: 2 minutes  

---

# What is the difference between constructor and method?

A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator.\
\
A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.\
Constructor does not have a return type.\
Name of constructor is the same as that of class in which it is declared.\
\
\

```
public class ClassA {public ClassA(){// Initilize code in the constructor.}}
```

\

## Answers

### Answer by Pushpendra Singh

A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator.\
\
A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.\
Constructor does not have a return type.\
Name of constructor is the same as that of class in which it is declared.\
\
\

```
public class ClassA {public ClassA(){// Initilize code in the constructor.}}
```

\


---

Original Source: https://www.mindstick.com/interview/163/what-is-the-difference-between-constructor-and-method

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
