suppose with the following code, does JVM always create instance of Object class, since Object is parent for all the classes the in Java.
class MyTestclass{
void printMe(String name){
System.out.println('I am '+name);
}
public static void main(String args[]){
MyTestclass obj = new MyTestclass();
obj.printMe("stackOverFlow.com");
}
}
Another class say TestClass2
class TestClass2{
void printMe(String name){
System.out.println('I am '+name);
}
public static void main(String args[]){
MyTestclass obj = new MyTestclass();
TestClass2 obj2 = new TestClass2();
obj.printMe("stackOverFlow.com");
obj2.printMe("stackOverFlow.com");
}
}
Will JVM creates two object instances if i run these two classes?
-XX:+UseEscapeAnalysisIn practice it rarely does this.