Multiple choice technology programming languages

package inheritance; class TestInheritance1 { public int empId =100; public String name ="tcs" ; } package inheritance1; import inheritance.TestInheritance1; public class TestInheritance_1 extends TestInheritance1 { public static void main(String[] args) { System.out.println("EmpId is "+empId); } }

  1. EmpId is 100

  2. Compiler error

  3. EmpId is 0

  4. Exception

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

The program fails to compile because TestInheritance1 is package-private and cannot be imported outside its package. Additionally, the non-static instance variable 'empId' is accessed directly inside the static main method without an object instance.