79.9k views
3 votes
Language: JAVA Can someone please tell me what the problem to my "main" class is?

I included the errors I received when trying to compile as well as the "Student" class which is used to answer the problem.

Here's the expected output:
Bob : 1234
Sue : 5678
Pat : 2468
Then it accepts user input: Chris

Then it outputs the updated objects:
Bob : 1234
Sue : 5678
Pat : 2468
Chris
Bob : 1234
Sue : 5678
Chris : 2468

Language: JAVA Can someone please tell me what the problem to my "main" class-example-1
Language: JAVA Can someone please tell me what the problem to my "main" class-example-1
Language: JAVA Can someone please tell me what the problem to my "main" class-example-2
Language: JAVA Can someone please tell me what the problem to my "main" class-example-3
User Greg Ross
by
4.7k points

1 Answer

6 votes

Answer:

please find the attachment of the correct code:

Output:

Bob : 1234

sue : 5678

pat : 2468

please enter a name to replace with pat:

Chris

Bob : 1234

sue : 5678

Chris : 2468

Explanation:

In this code, when we create the class object, that is "stu1, stu2, and stu3" and call the parameterized constructor bypassing the "string and integer" value and print the object value you forget to call the "tostring" method because it is the only method which returns both "string and integer" value.

Language: JAVA Can someone please tell me what the problem to my "main" class-example-1
Language: JAVA Can someone please tell me what the problem to my "main" class-example-2
Language: JAVA Can someone please tell me what the problem to my "main" class-example-3
User Vitorbal
by
5.9k points