My question is - When I print value of the String name, it's null(which is understandable). But, is it because of JVM default constructor or because of the one I provided? What I assume is if I provide constructor, it will be called and JVM will not call the default constructor. But my constructor is empty so who sets null for string?
class Animal{
String name;
//no-arg constructor I provided which does nothing
Animal(){
}
void printName() {
System.out.println("name: "+name);
}
public static void main(String[] args) {
Animal cat = new Animal();
cat.printName()
}
}