A class called Robot contains the following two instance variable declarations:
private ushort age; private bool isConnected;
What is the value of age and isConnected immediately after their object has been instantiated?
Improve the style of the declarations without changing the semantics of the code.
The users of your Robot class would like to assign a value to age at the same time as they are instantiating a Robot object. How would you accommodate for this request?
What constructor names can you use for a class called Robot?
Are constructors only used to initialize instance variables?
What is the return type of a constructor?
The following line creates a new Cat object. What do the parentheses after Cat signify?
Cat myCat = new Cat();
How can overloaded constructors make a class more flexible to use?
Why would you ever want a constructor that cannot be called from outside its class? How do you declare this kind of constructor? What is it called?
When is a static constructor called?
Could you design a program that allows the end user to assign a value to a:
Hint: What is the lifetime of a constant member? What is the lifetime of a readonly instance member?
Briefly explain what it means for an object to be out of reach.
What are the two main tasks of the garbage collector?
Why does the garbage collector not just garbage collect any object that goes out of reach immediately?
What is a destructor? Why is it not useful for freeing up scarce non-memory resources?
A program contains a class called Book that contains 10 instance variables all of a simple type. During the execution of the program, 50 Book objects are created and most of them are destroyed. Is the garbage collector likely to run during the execution of your code?
Why should you be careful when using C# (at this time of writing) for real time applications?
Briefly explain why it is a good idea to use the Dispose design pattern to free scarce non-memory resources.