When creating 2 objects of the same type, will the handle from the stack memory point to the same object in the heap or will it point to 2 separate objects. For clarity here is the specific question...
class Q2 {
private static int num = 0;
private String prefix;
public Q2 (String p)
{ prefix = p; }
public String Msg (String str) {
String n;
num++;
n = num.ToString();
return n + " - " + prefix + str;
}
}
Using an appropriate diagram, describe the state of memory after all of the following statements have been executed.
Q2 var1, var2;
var1 = new Q2("Question 2");
var2 = new Q2 ("Another view");
Here are the answers I cannot decide between:
1 object:
2 objects: