O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Review Questions

1: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.

2: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?
3:What constructor names can you use for a class called Robot?
4:Are constructors only used to initialize instance variables?
5:What is the return type of a constructor?
6:
  1. A Dog class contains no constructor definitions in the source code. Is the following statement ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required