G
gk
public class PowerSupply
{
public PowerSupply(String voltage){
System.out.println ("PowerSupply(String) executed");
}
public PowerSupply(Object voltage){
System.out.println ("PowerSupply(Object) executed");
}
public PowerSupply(){
System.out.println ("No argument constructor execute");
}
public static void main(String[] args) {
PowerSupply ps = new PowerSupply(null);
}
}
what would be the output ?
output: PowerSupply(String) executed\
i dont know why the JVM is choosing the first constructor for
argument null .
please explain...how this output coming ?
{
public PowerSupply(String voltage){
System.out.println ("PowerSupply(String) executed");
}
public PowerSupply(Object voltage){
System.out.println ("PowerSupply(Object) executed");
}
public PowerSupply(){
System.out.println ("No argument constructor execute");
}
public static void main(String[] args) {
PowerSupply ps = new PowerSupply(null);
}
}
what would be the output ?
output: PowerSupply(String) executed\
i dont know why the JVM is choosing the first constructor for
argument null .
please explain...how this output coming ?