Doubt in abstract classes
        Posted  
        
            by mohit
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by mohit
        
        
        
        Published on 2010-04-21T09:11:27Z
        Indexed on 
            2010/04/21
            9:13 UTC
        
        
        Read the original article
        Hit count: 292
        
java
public abstract class Person {
private String name;
public Person(String name) {
    this.name = name;
    System.out.println("Person");
}
public String getName() {
    return name;
}
abstract public String getDescription();    
}
public class Student extends Person {
private String major;
public Student(String name, String major) {
    super(name);
    this.major = major;
}
public String getMajor() {
    return major;
}
@Override
public String getDescription() {
    return "student" + super.getName() + " having" + major;
}
}
public class PersonTest {
public static void main(String[] args) {
    Person person = new Student("XYZ", "ABC");
    System.out.println(person.getDescription());
}
}
Ques: We cannot create objects of abstract classes, then why Person Constructor has been invoked, even its an abstract class?
© Stack Overflow or respective owner