Computer Science, asked by rajendraaryanr2089, 1 year ago

What is difference between constructor and method?

Answers

Answered by vishavgupta988
1

Answer:

There are a lot of difference . Constructor is used to initialise the value of object as soon as object is created but method is not doing this task.

Constructor has no return type but method has return type.

Constructor have same name as of class name but this is not case of method.

For Example

class A

{

A() //it is constructor

{

//body

}

public void X()

{

// this is method

}

}

Answered by singhpragya0309
0

Answer:construtor has no return type while method has a return type.

A constructor has a same class name but a method may not have the same class name.

Explanation:

Similar questions