Complete the code to declare an instance field named 'count' of type int.
public class Counter { private [1] count; }
The instance field 'count' should be declared with the type int to store integer values.
Complete the code to initialize the instance field 'count' to zero in the constructor.
public class Counter { private int count; public Counter() { [1] = 0; } }
The instance field 'count' is assigned the value 0 inside the constructor by using its name directly.
Fix the error in the method to correctly increment the instance field 'count'.
public class Counter { private int count; public void Increment() { [1]++; } }
The method should increment the instance field 'count' by using its name directly.
Fill both blanks to create a method that returns the current value of the instance field 'count'.
public class Counter { private int count; public [1] GetCount() { return [2]; } }
The method should return an integer, so its return type is int, and it returns the instance field count.
Fill all three blanks to define a class with an instance field, a constructor that sets it, and a method that returns it.
public class Person { private string [1]; public Person(string [2]) { this.name = [2]; } public string GetName() { return [3]; } }
The instance field is named 'name'. The constructor parameter is also 'name'. The method returns the field 'name'.