Create a static Set callerClasses to hold the name of each class that called your Demo class.
Then, at each call to your Demo class, add the caller name to the set.
At any point in time you can check how many different classes called your Demo class by inspecting the Set size.
EDIT NOTE #1:
The question was made clear after I posted my answer that the intention is not count for calls on methods but count instances created.
I will keep it anyway because this may be the case for someone else.
EDIT NOTE #2:
Added code sample for completeness.
public class Demo {
// ConcurrentSkipListSet for thread safety
private static Set<String> callerCount = new ConcurrentSkipListSet<>();
public void methodA() {
String className = new Exception().getStackTrace()[1].getClassName();
recordCaller(className);
}
public long getNumberOfCallers() {
return callerCount.size();
}
private void recordCaller(final String className) {
callerCount.add(className);
}
}