Sunday, 8 January 2012

Question 91 : Inheritance

Given:
class Person {
String name = "No name";
public Person(String nm) { name = nm; }
}

class Employee extends Person {
String empID = "0000";
public EmployeeTest {
public static void main (String[] args) {
Employee e = new Employee("4321");
System.out.println(e.empID);
}
}
What is the result?

A. 4321
B. 0000
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 18.

No comments:

Post a Comment