What is printed by the following program?
public class Example {
protected int num;
public Example(int initial) {
num = initial;
}
public int getNum() {
num = num + 1;
return num;
}
public static void main(String args[]) {
Example first = new Example(10);
Example second = new Example(20);
System.out.println(first.getNum());
System.out.println(second.getNum());
}
}
What would be printed if we changed the declaration of num to be
protected static int num;
What does this tell you about static fields?