Multiple choice technology programming languages

12 You have these files in the same directory. What will happen when you attempt to compile and run Class1.java if you have not already compiled Base.java //Base.java package Base; class Base{ protected void amethod(){ System.out.println("amethod"); }//End of amethod }//End of class base package Class1; //Class1.java public class Class1 extends Base{ public static void main(String argv[]){ Base b = new Base(); b.amethod(); }//End of main }//End of Class1

  1. a. Compile Error: Methods in Base not found

  2. b. Compile Error: Unable to access protected method in base class

  3. c. Compilation followed by the output "amethod"

  4. d. Compile error: Superclass Class1.Base of class Class1.Class1 not found

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Class1 is in package Class1, Base is in package Base. Class1 extends Base. When Class1 tries to create 'new Base()', the compiler looks for Base.Class1.Base (inner class interpretation) because of how package names interact. The actual Base class is in a different package and isn't found with that qualification. This causes 'Superclass Class1.Base of class Class1.Class1 not found' - the compiler is confused about the class hierarchy due to package naming.