Given:
2. interface Shape { 3. int size = 7; 4. void grow(); 5. } //from ww w . j a v a2 s . c om 6. class Main implements Shape { 7. // static int size = 5; 8. // int size = 5; 9. public static void main(String[] args) { 10. int size = 2; 11. new Main().grow(); 12. } 13. public void grow() { 14. System.out.println(++size); 15. } }
Which are true? (Choose all that apply.)
C, D, and E are correct.
As the code stands, the grow()
method will try to increment Shape's size variable, which can't be changed because it's final by default, so the code will not compile.
If either line 7 or 8 is uncommented, then the grow()
method will use that line's size variable.