MCQs > IT & Programming > Java > Consider the following code: MyClasscls = new MyClass('Test Class'); System.out.println(cls); What is the best implementation for printing 'Test Class' to the output?

Java MCQs

Consider the following code: MyClasscls = new MyClass("Test Class"); System.out.println(cls); What is the best implementation for printing "Test Class" to the output?

Answer

Correct Answer: Override the toString method in this class and return the string which passes in the constructor.

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it