title: Java- Getters Returning Null
body: <p>I am working on an abstract superclass exercise for class, and I am stuck on why my getters are returning null. According to how my instructor demonstrated, the setters are overridden in the subclasses, and the getters are to be final methods in the superclass. The getters work when I move them to the subclass, so I am guessing that it has something to do with the fact that they are in separate classes, but as I am brand new to object oriented programming, I have no idea if that is why and/or how to go about correcting this. </p>
  
  <p>Abstract Superclass: </p>
  
  <pre><code>public abstract class ProgrammingCourse {
  
      private double credits;
      private  String courseName;
  
      public final double getCredits() {
          return credits;
      }
  
      public abstract void setCredits(double credits);
  
      public final String getCourseName() {
          return courseName;
      }
  
      public abstract void setCourseName(String courseName);
  </code></pre>
  
  <p>Sample Subclass: </p>
  
  <pre><code>  public class AdvancedJavaCourse extends ProgrammingCourse {
  
      private double credits;
      private String courseName;
  
      @Override
      public void setCourseName(String courseName) {
          if (courseName == null || courseName.length() == 0) {
              JOptionPane.showMessageDialog(null,
                      "Error: courseName cannot be null or empty");
              System.exit(0);
          }
          this.courseName = courseName;
      }
  
      @Override
      public void setCredits(double credits) {
          this.credits = credits;
      }
  </code></pre>
  
  <p>How I am trying to work with this in my main:</p>
  
  <pre><code>     ProgrammingCourse[] courses = {new AdvancedJavaCourse(), 
       new IntroJavaCourse(), new IntroToProgrammingCourse()};
  
      courses[0].setCourseName("adv Java");
      courses[1].setCourseName("Intro Java");
      courses[2].setCourseName("Intro Programming");
      for (ProgrammingCourse pc : courses) {
          System.out.println(pc.getCourseName());
      }
  
      AdvancedJavaCourse advJava = new AdvancedJavaCourse();
      advJava.setCourseName("Advanced Java");
  
      System.out.println(advJava.getCourseName());
  </code></pre>