Ineed help with the following problem. It is being programmed in Java at a very
ID: 3762537 • Letter: I
Question
Ineed help with the following problem.
It is being programmed in Java at a very basic level.
1. MyClone accessors and mutators: You will demonstrate your understanding of encapsulation by creating accessor and mutator methods for all instance variables of the MyClone class.
2. MyClone constructor: You should have at least one constructor created that initializes all instance variables.
3. MyClone method introduction(): Create an introduction() method for your MyClone class. The introduction() method will introduce you to the virtual world by displaying a greeting, your first and last name, and anything else you would want to say.
4. Constructor: You will implement at least one constructor that initializes all instance variables.
Please comment on code to aid in understanding, beginning level.
Thanks,
Explanation / Answer
public class MyClone {
// My Clone class has three Strings
private String FirstName;
private String LastName;
private String Hobbies;
//My clone class has
// one constructor
public MyClone(String FirstName, String LastName, String Hobbies){
FirstName = startFirstName;
LastName = startLastName;
Hobbies = startHobbies;
}
public String getFirstName(){
return FirstName;
}
public int LastName(){
return LastName;
}
public String getHobbies(){
return Hobbies;
}
public void setFirstName(String FirstName){
FirstName = newFirstName
}
public void setLastName(String LastName){
LastName = newLastName
}
public void setHobbies(int Hobbies){
Hobbies = newHobbies
}
public void introduction()
{System.out.println("Hi there! My name is");
System.out.println("the first name is " + FirstName);
System.out.println("My last name is " + Lastname);
System.out.println("over");
public static void main (String[] args){
Myclone n= new myclone("ankit","roy","cricket");
n.introduction();
}
}
}