Study your flashcards anywhere!

Download the official Cram app for free >

  • 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

How to study your flashcards.

Right/Left arrow keys: Navigate between flashcards.right arrow keyleft arrow key

Up/Down arrow keys: Flip the card between the front and back.down keyup key

H key: Show hint (3rd side).h key

A key: Read text to speech.a key

image

Play button

image

Play button

image

Progress

1/33

Click to flip

33 Cards in this Set

  • Front
  • Back
  • 3rd side (hint)
Most reference types are (choose one)

a. Built-in.
b. User created.
c. Stored on the stack.
d. unstructured.
b. User created.

The following keywords are used to declare reference types:

class
delegate
interface
C# is a class act.
What are the keywords that are used to declare reference types?
class
delegate
interface
CDI
What are the built in reference types?
string
object
SO!
Both 'classes' and 'structs' are data structures. Name three differences.
1. instances of classes are stored on the heap. Structs are stored on the stack.
2. (some) classes can be inherited. Structs cannot.
3. Classes must be instantiated using the 'new' operator. Structs can be instantiated by simple declaration.
Name three kinds of members that a class might contain.
data members
functional members
nested types
FiND
Name all the type of functional members that a class may contain. There are 8.
1. methods
2. properties
3. events
4. indexers
5. operators
6. instance constructors
7. destructors
8. static constructors
PEt IDIOMS
Show all the components of a class declaration.
[attributes] [modifiers] class identifiers [:base-list] {class-body}[;]
What parts of a class declaration are required?
class identifier {body}
There are many attributes but two are important in controlling versions and configuration. What are they? How are they used?

Note: attributes will be covered in detail in a separate deck.
[Conditional conditionalSymbol] -- used to control execution based upon the presence or absence of the conditionalSymbol (preprocessor identifier).
[Obsolete message, iserror]--Marks an entity that should not be used. message is used to explain why and iserror (boolean) if true will cause a compile error if the entity is used. If false it will generate a warning.
What are the allowed modifiers for a class?
new
abstract
sealed
public
internal
protected
private
There are seven.
Does C# support multiple inheritance.
Not from classes. But, a class can inherit from one class and multiple interfaces.
Can a class inherit from a struct?
No, but a class can use a struct.
What is the form of a 'delegate' declaration?
[attributes] [modifiers] delegate result-type identifier ([formal-parameters]);
What is the purpose of a delegate?
A delegate allows a program to pass a function as a parameter. It is similar (but not identical to) a function pointer in C++.
It's what you can pass.
What modifiers are permitted for a 'delegate'.
new
public
internal
protected
private
There are 5.
What are the restrictions on the function that you can pass with a 'delegate'?
A function that is passed by a delegate must have the same signature as the delegate. The signature is the type and order of parameters (if any) and return type (if any).
Show the form of a 'interface' declaration.
[attributes] [modifiers] interface identifier [:base-list] {interface-body][;]
What modifiers are allowed for the interface type?
new
public
protected
internal
private
There are 5.
What is the purpose of an interface?
An interface is a 'contract' between the implementing object and the interface that says that the object will implement the referenced interface.
It's a contract.
What kinds of things can an interface define.
methods
properties
events
indexers
Does an interface implement the defined behaviors?
No. It is the responsibility of the inheriting object to define the behavior of the interface members.
What restrictions if any are place upon the inheriting object when implementing interfaces?
The signatures of the methods, properties, events and indexers must be honored.
Where can an interface be declared?
An interface can be a member of a workspace or a class.
What kinds of members can an interface declare?
Methods
Indexers
Properties
Show a simple example of an interface declaration called ISize that consists of a scalar value for an arbitrary size.
// ISize interface
interface ISize
{
// signatures
int x
{
get;
set;
}
}
Create a simple class that implements ISize. Call the class mySize.
class mySize : ISize //inherits ISize
{

//add private field for size
private int theSize

//constructor
public mySize(int x)
{
theSize = x;
}

//Implement the property
public int x
{
get
{
return theSize;
}

set
{
theSize = value;
}
}
}
'object' is a built-in reference type. What kinds of things can you assign to an 'object' type?
Any type can be assigned to an 'object' type variable.
'string' is a built in type. What kinds of things can be assigned to a string type variable.
Any sequence of Unicode characters.
Show the escape sequence for the unicode character 'A'.
string s = "\\\u0065";
Write an expression that will return the 'a' from the string "cSharp".
char x = "cSharp"[3];
If you build a struct but do not initialize its members in the declaration, what will the values of its members be?
value types will have the system default values
reference types will be set to 'null'
What value types support an implicit cast to type 'char'?
None.
What is the value of 'x' in the following operation?

float x = (float) 2x10^300;
x is set to infinity.