title: How to test default constructor in a different class in Java
body: <p>How do you test a default constructor in one class and then test it in a different class?
  This is the code for the Person class which has the default constructor.
  I'm not sure in the PersonTester class how to access this default constructor and how to test it - what I have so far for the second class is also below. </p>
  
  <p>Any help will be muchly appreciated, thanks :)</p>
  
  <pre><code>class Person {
  
      // Data Members 
      private String name; // The name of this person
      private int age; // The age of this person
      private char gender; // The gender of this person
  
      // Default constructor
      public Person() {
          name = "Not Given";
          age = 0;
          gender = 'U';
      }
  
      // Constructs a new Person with passed name, age, and gender parameters.
      public Person(String personName, int personAge, char personGender) {
          name = personName;
          age = personAge;
          gender = personGender; 
      }
  
      // Returns the age of this person.
      public int getAge( ) {
          return age;
      }
  
      // Returns the gender of this person.
      public char getGender( ) {
          return gender;
      }
  
      // Returns the name of this person.
      public String getName( ) {
          return name;
      }
  
      // Sets the age of this person.
      public void setAge( int personAge ) {
          age = personAge;
      }
  
      // Sets the gender of this person.
      public void setGender( char personGender ) {
          gender = personGender;
      }
  
      // Sets the name of this person.
      public void setName( String personName ) {
          name = personName;
      }
  
  } // end class    
  
  import java.util.Scanner;
  
  public class PersonTester {
  
      // Main method
      public static void main(String[] args){
  
          // TEST THE DEFAULT CONSTRUCTOR FIRSTLY.
  
          // Create an instance of the Person class.
          Person person1 = new Person();
  
          Scanner input = new Scanner(System.in);
  
          // Get the values from user for first instance of Person class.
          System.out.println("Person 1 Name: ");
          person1.setName(input.nextLine());
  
          System.out.println("Person 1 Age: ");
          person1.setAge(input.nextInt());
  
          System.out.println("Person 1 Gender: ");
          person1.setGender(input.next().charAt(0););
  
          // Alternatively assign values to the Person class.
          // person1.setName("Not Given");
          // person1.setAge(0);
          // person1.setGender("U");
      }
  }
  </code></pre>