Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

First ClassOOPS.java x ClassClient.java x DG Source History 4 package FirstClass

ID: 3831830 • Letter: F

Question

First ClassOOPS.java x ClassClient.java x DG Source History 4 package FirstClassooPS public class FirstClassooPS Declare Variables 8 private String sName private int Sage 10 Create default constructor 11 12 public FirstclassooPS 13 E 14 sName. None 15 Sage 18 16 L 17 Create a constructor 18 public FirstClassooPS (String name, int age) A 19 20 //initialize variables 21 sName name 22 Sage age 23 24 Mutator Method Method that changes the name 25 public void setName (String name) 26 E 27 sName name 28 L 29 Mutator Method Method that changes the age 30 public void setAge (int age) A 31 32 sage age 33 34 //Getter Method Method that returns the value of Name 35 public String getName 36 37 return sName: 38 39 //Getter Method Method that returns the value of age 40 public int getAge A 41 42 return sage 43 44 To String Method returns the name and age public String toString 46 String message "My name is "tsName InMy age is sage 47

Explanation / Answer

Please find my answer:

public class ClassClient {

   public static void main(String[] args) {

       //Create a FirstClassOOPS variable with name = John Smith and age = 62

       FirstClassOOPS g = new FirstClassOOPS("John Smith", 62);

       String outPutString = g.toString();

       System.out.println(outPutString);

       // The output should be // My name is John Smith. // My age is 62. //

   }

}

/*

Sample run:

My name is John Smith.

My age is 62.

*/