1. Provide Java code for a simple class of your choice. Be sure to include at least one constructor, two methods and two fields. The fields should be private.
2. Create a test class to constuct and call the methods of your class.
3. Describe your class and demonstrate your code functions properly.

Respuesta :

Answer:

Explanation:

public class Main

{

public static void main(String[] args) {

 System.out.println("Test Class:");

 Name name = new Name("Dayanand","Ghelaro");

 System.out.println("First Name : "+name.getFirstName());

 System.out.println("Last Name : "+name.getLastName());

}

}

class Name{

   private String firstName;   // first name field

   private String lastName;    // last name field

   public Name(String firstName, String lastName){

       this.firstName = firstName;

       this.lastName = lastName;

   }// end of constructor

   public String getFirstName(){

       return this.firstName;

   } // end of method

   public String getLastName(){

       return this.lastName;

   }// end of method

}// end of Name class

Ver imagen dayanandghelaro