0
In a class,if we have a constructor and methods with same name and without argument is this is possible to have like this?
please tell me
7 Respuestas
+ 6
Yes, it's possible. Constructors don't have any return type, not even void. This is how constructors can be differentiated from other methods. The following code is valid:
class Person{
// data fields
Person(){
// constructor
}
void Person(){
// this is a method
}
}
+ 1
Yes ,Constructor and method(function) can have same arguments ...As constructor doesn't have any return type so constructor n method can be differentiated ...Hope u understood ...
+ 1
@Vani yes it is possible to have constructor n method having same argument ,same name in one class ....
0
Which language ?
0
in java
0
is it possible to have a constructor and method both having same argument,same name in one class?!
0
Sorry, I don't know java. please add java to your tags