Question: Why are the following assignments all invalid? Please can you explain why for each individual assignment. I had thought one or two of them were okay given we imported toyPackage.
Given the classes below, indicate whether the assignments are valid or invalid. Notice that we are using two packages.
package toyPackage; public class Toy { protected int size; static int max; public static final int temp = 10; }
package experiment; import toyPackage.*;
public class Driver { public static void main(String[] args) { Toy p = new Toy(); p.size = 10; /* Invalid / p.max = 20; / Invalid / Toy.max = 30; / Invalid / Toy.temp = 40; / Invalid */ } }