q1: Write a public class named Gene with the following A public constructor that
ID: 3732466 • Letter: Q
Question
q1: Write a public class named Gene with the following A public constructor that takes 2 Strings. The Strings should be stored in instance variables * -A public method named replaceChar that takes no parameters and has return type void. This *method removes all instances of the character 'y' from the instance variable storing the * String that was the first parameter in the constructor call *An overridden toString method that returns the stored strings separated by spaces. This * includes all the Strings from the constructor call and if replaceChar was called on this *instance then the first String will not contain any instances of 'yExplanation / Answer
//Gene.java public class Gene { private String s1; private String s2; public Gene(String s1, String s2) { this.s1 = s1; this.s2 = s2; } public void replaceChar(){ s1 = s1.replaceAll("y",""); } @Override public String toString() { return s1 + " "+s2; } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.