CS Electrical And Electronics
@cselectricalandelectronics

Which of the following statements describe the class definition and instantiation in the sample code?

All QuestionsCategory: Cpp LanguageWhich of the following statements describe the class definition and instantiation in the sample code?
Anonymous asked 3 years ago
public class Dog
{
     public String name;
     public Dog()
     {
          name = "Max";
     }

     public Dog(String nm)
     {
          name = nm;
     }

     public void setName(String name)
     {
          this.name = name;
     }
}


Options:

  1. The setName method can be used to modify data in the class definition
  2. The class definition represents a Dog
  3. There are two constructor methods that could be used to create the name string
  4. The class definition contains a single piece of data
  5. An instance of the class is created
 
1 Answers
Anonymous answered 3 years ago

The correct answers are:

  1. The setName method can be used to modify data in the class definition
  2. The class definition represents a Dog
  3. There are two constructor methods that could be used to create the name string
  4. The class definition contains a single piece of data