Imagine this extreme situation:
A class City with 10 variables, but 1000 lines of functions and logic that operates these variables.
Class Person {
// 10 variables
int age = 20;
int height = 180;
String name = "Name";
.
.
.
// 1000 lines of functions and logic
public void increaseAge(int years){
age+=years;
}
public void doLogic(){
//some logic
}
.
.
.
}
I don't know exactly how much memory will occupy a instance of this class, but let's say that the variables occupy 10 bytes and the 1000 lines of functions occupy 1 kb to put a sample amount.
If you have 100 instances of that class, the 100 times repeated variables should occupy 10*100 bytes but what happens with the functions? will you have 1*100 kb memory occupied for these functions? Or will the compiler do something to avoid that?