C# Flashcards

1
Q

sealed

A

prevents a class from being inherited

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

private

A

The code is only accessible within the same class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

public

A

The code is accessible for all classes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

protected

A

The code is accessible within the same class, or in a class that is inherited from that class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

internal

A

The code is only accessible within its own assembly, but not from another assembly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

static

A

The method belongs to the Program class and not an object of the Program class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

void

A

The method does not have a return value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

properties

A

A property is like a combination of a variable and a method, and it has two methods: a get and a set method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

field

A

A variable declared directly in a class. Best practice to start name with lower case letter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Properties and fields naming convention

A

Best practice to start name of a Property an with uppercase letter and the name of a field with a lower case letter.

Ex:
class Person {
private string name; // field

  public string Name   // property
  {
    get { return name; }   // get method
    set { name = value; }  // set method
  }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Method Overloading

A

With method overloading, multiple methods can have the same name with different parameters.

Ex:
int MyMethod(int x)
float MyMethod(float x)
double MyMethod(double x, double y)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

virtual

A

Indicates that a class member can be overridden by an inherited class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

override

A

Indicates that a class member will override a virtual class member from the parent class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

class member

A

Fields or methods within a class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Abstract class

A

A restricted class that cannot be used to create objects (to access it, it must be inherited from another class).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Abstract method

A

A method that can only be used in an abstract class. It does not have a body. The body is provided by the derived class (inherited from).

17
Q

interface

A

An interface is a completely “abstract class”, which can only contain abstract methods and properties (with empty bodies).

By default, members of an interface are abstract and public.

18
Q

interface naming convention

A

It is considered good practice to start with the letter “I” at the beginning of an interface, as it makes it easier for yourself and others to remember that it is an interface and not a class.

19
Q

enum

A

An enum is a special “class” that represents a group of constants (unchangeable/read-only variables).

To create an enum, use the enum keyword (instead of class or interface), and separate the enum items with a comma: