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

Title pretty much says what I have to do . I am new to java and am struggling wi

ID: 3556589 • Letter: T

Question

Title pretty much says what I have to do . I am new to java and am struggling with this question. Please Help!!

public class ClassA {

private String s1, s2;

private static int numClassA;

// Initializes s1 and s2 and keeps track of the number of ClassA objects created//

public ClassA (String s1, String s2) {

this.s1 = s1;

this.s2 = s2;

++numClassA;

}

//Sets both s1 and s2 to parameter s1 and keeps track of the number of ClassA objects created//

public ClassA(String s1) { // Student completion//

}

/**

*Returns true if s1 equals s2, false otherwise

*@return true if s1 equals s2, false otherwise

*/

public one() { //Student completion

}

/**

*STATIC method that returns the number of ClassA objects created

*@return the number of ClassA objects created

*/

public numClassA() { // Student completion

}

public String toString() {

return s1 + ", " + s2;

}

}

Explanation / Answer

public class ClassA
{
private String s1, s2;
private static int numClassA;
// Initializes s1 and s2 and keeps track of the number of ClassA objects created//
public ClassA (String s1, String s2) //CONSTRUCTOR
{
this.s1 = s1;
this.s2 = s2;
++numClassA;
}
//Sets both s1 and s2 to parameter s1 and keeps track of the number of ClassA objects created//
public ClassA(String s1) //CONSTRUCTOR
{
this.s1 = s1;
this.s2 = s1;
++numClassA;

}
/**
*Returns true if s1 equals s2, false otherwise
*@return true if s1 equals s2, false otherwise
*/
public int one()
{
if (s1.compare(s2) == 0)
return 1; //returns TRUE

else
return 0; //returns FALSE

}
/**
*STATIC method that returns the number of ClassA objects created
*@return the number of ClassA objects created
*/
public int numClassA()
{
return numClassA;

}

public String toString()
{
return s1 + ", " + s2;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote