title: Java - Abstract classes and concrete classes
body: <p>I'm working on my assignment but I got confused with the abstract classes and concrete classes, and I get error from my program...</p>
  
  <p>Suppose there is an abstract class Person and a concrete subclass Student:</p>
  
  <pre><code>abstract class Person{
      private String name;
      public Person(String s){
            name = s;
      }
      public String getName() {
            return name;
      }
      public abstract void doAction(Person other);
  }
  
  class Student extends Person{
      public Student(String name){
            super(name);
      }
      public void doAction(Person other){
            System.out.println("This person's name is " + getName());
      }
  }
  </code></pre>
  
  <p>Then I implement a main function to test it but I got an error...:</p>
  
  <pre><code>public class TestMain {
      public static void main(String[] args) {
          Person person;
          Student student;
  
          person = new Student("Sam");
          student = person;
          student.doAction(person);
      }
  }
  </code></pre>
  
  <p>It is said <code>student = person</code> receiving an error saying that <code>"Error: Incompatible types: Person cannot be converted to Student"</code>. What's wrong with that actually and why...? Does anyone can explain this...?</p>