• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/19

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

19 Cards in this Set

  • Front
  • Back

What's the difference between properties and fields in a class?

Properties are public and have getters and/or setters. Fields are private.

By convention, what types of objects use camel case?

Fields, variables, parameters

By convention, what types of objects are Pascal case?

Classes, properties, constants

What are the four types of properties?

Full, Automatic, Read Only, Read Only with Initialization

What is a full property?

One where everything is explicitly written. E.g.,




public string Name {


get {return name;}


set {name = value;}


}

What is an automatic property?

One where the compiler takes care of the getter and setter. E.g.,




public string Name {get; set;}

What is a read only property?

One which only has a setter.

What syntax is used to initialize a property?

public string Name {get;} = "John";

Does a constructor have any return value?

No, not even void.

If you've defined a constructor that takes parameters but not a default constructor, will the compiler create a default constructor for you?

No, the compiler will only generate a default constructor if no constructors were explicitly defined.

How do you indicate a derived class?

Place a colon and the parent class name after the class name in the class definition.

True or false. To override a method in a base class, define a new method in the derived class with the same paramaters and return type.

False. You must also use the override keyword before the method name.

How do you pass a parameter directly to the base class?

After the closing parenthesis of the parameter list put this -




:base(parameters from parameter list to be passed to base class here)

What is the convention for naming an interface?

Interfaces should start with a capital I.

What methods of an object can you access if you declare a variable as an interface type?

Only the methods defined in the interface.




E.g., if you declare




IStorable a = new Document();




then you can only access the methods of document that were defined in the IStorable interface.

Should you mark methods defined in an interface as public or private?

No, you can't specify whether methods defined in an interface are public or private.

If a property and field have the same name and capitalization, how can you differentiate between them?

Use "this.field" to reference the field and "field" to reference the property.

You declare a method in a child class with the same signature as a method in the base class. The method in the base class is not marked as virtual, abstract or override.Will you get any compiler errors/warnings or run-time errors?

You'll get a compiler warning that the method hides a method in the base class.

You declare a method in a child class with the same signature as a method in the base class. The method in the base class is not marked as virtual, abstract or override. What happens if you declare a variable as an object of the base class type and call that method?

It will call the method in the base class?