Multiple choice technology programming languages

package inheritance; class TestInheritance4 { String name ="TCS"; } package inheritance1; import inheritance.TestInheritance4; public class TestInheritance_4 extends TestInheritance4 { void printName() { System.out.println("name ="+name); } public static void main(String[] args) { TestInheritance_4 T_4 = new TestInheritance_4(); T_4.printName(); } }

  1. Compiler Error

  2. name = TCS

  3. name = null

  4. Exception

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

The code fails to compile because the field 'name' has default (package-private) access in TestInheritance4. Default access is restricted to the same package only. Since TestInheritance_4 is in a different package (inheritance1), it cannot access 'name'. Options B and C are wrong because the code won't reach runtime. Option D is wrong because this is a compile-time access violation, not a runtime exception.