Terminology Flashcards

1
Q

what is a class?

A

A class is like a blueprint of a specific object. A class enables you to create your custom types by grouping variables of other types, methods, and events.

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

What is the difference between a class and an object?

A

In c#, Classes and Objects are interrelated. The class in c# is nothing but a collection of various data members (fields, properties, etc.) and member functions. The object in c# is an instance of a class to access the defined properties and methods.

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

What are namespaces in c# .NET?

A

Namespaces are used in C# to organize and provide a level of separation of codes. They can be considered as a container which consists of other namespaces, classes, etc.

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

what is a boolean and what is it’s default value?

A

Boolean value= True or False default: False

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

what is a byte and what is it’s range and default value?

A

8-bit unsigned integer from 0 to 255 default=0

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

name 3 variable types that require a letter also-

A

decimal =m double = d float = f

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

what is type conversion and what are it’s 2 forms?

A

Type conversion is converting one type of data to another type. It is also known as Type Casting. In C#, type casting has two forms − Implicit type conversion − These conversions are performed by C# in a type-safe manner. For example, are conversions from smaller to larger integral types and conversions from derived classes to base classes. Explicit type conversion − These conversions are done explicitly by users using the pre-defined functions. Explicit conversions require a cast operator. example: ———————————————- Using System; namespace TypeConversionApplication { class StringConversion { static void Main(string[] args) { int i = 75; float f = 53.005f; double d = 2345.7652; bool b = true; Console.WriteLine(i.ToString()); Console.WriteLine(f.ToString()); Console.WriteLine(d.ToString()); Console.WriteLine(b.ToString()); Console.ReadKey(); } } }

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

what is a variable?

A

A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C# has a specific type, which determines the size and layout of the variable’s memory the range of values that can be stored within that memory and the set of operations that can be applied to the variable.

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

What is an interface?

A

basically like a contract-it tells a class what must be in it.

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

what are the 4 things an interface can define?

A
  1. methods 2. properties 3. indexes 4.events
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what forces a class to implement any of 4 pieces of information?

A

interfaces

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

are interfaces public or private?

A

interfaces are ALWAYS public

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

what is the naming convention for Interfaces

A

always start with capital “I” then the name such as “IMyInterface”

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

what is the default access modifier for Interfaces?

A

public- Interfaces must be public therefore if no access modifier is given the default is public

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

if you define a method within an Interface- what should the access modifier be?

A

you can drop the access modifier because Interfaces are always public

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

how do you define a method within Interfaces?

A

with only the method signature: void LogMessage(string message); normal declaration: public void LogMessage(string message) { Console.WriteLine(“your message”); }

17
Q

what is dependency injection and what is it’s intent?

A

Dependency Injection (DI) is a software design pattern. It allows us to develop loosely-coupled code. The intent of Dependency Injection is to make code maintainable. Dependency Injection helps to reduce the tight coupling among software components. Dependency Injection reduces the hard-coded dependencies among your classes by injecting those dependencies at run time instead of design time technically.

18
Q

what is a constructor?

A

A constructor is a special method of the class which gets automatically invoked whenever an instance of the class is created. Like methods, a constructor also contains the collection of instructions that are executed at the time of Object creation.

19
Q

name 7 important things to remember about constructors-

A
  1. Constructor of a class must have the same name as the class name in which it resides.
  2. A constructor can not be abstract, final, static and Synchronized.
  3. Within a class, you can create only one static constructor.
  4. A constructor doesn’t have any return type, not even void.
  5. A static constructor cannot be a parameterized constructor.
  6. A class can have any number of constructors.
  7. Access modifiers can be used in constructor declaration to control its access i.e which other class can call the constructor.
20
Q

what is a constructor?

A

a method that is called with an instance of a class is created

21
Q

why do we need a constructor?

A

the intention is to put an object in a early state

-that is to initialize some of the fields in the class

22
Q

what is constructor overloading?

A

having a method by the same name but different signatures

23
Q

what is a method signature?

A

a dignature is what uniquely identifies a method

that is:

its name

its return type

and the types and number of its perameters

24
Q

What is an object initializer?

A

a syntax for quickly initializing an object without the need to call one of its constructors

25
Q

why do we need object initializers?

A

to avoid creating multiple constructors

26
Q

what is the syntax for an object initializer?

A

see image

27
Q

what does it mean to overload a method?

A

having a method with the same name but different signatures

-see image

28
Q

how does one use the Params modifier and why?

A

when there are too many possible constructors the code -see image

one could use an array but then the array must be initialized before each use

instead use a Params Modifier

29
Q

What is an access modifier?

A

An access modifier is a way to control access to a control and/or its members (such as public or private)

30
Q

what is a property?

A

a property is a class member that encapsulates a getter/setter for accessing a field

A property is a member that provides a flexible mechanism to read, write, or compute the value of a private field. Properties can be used as if they are public data members, but they are actually special methods called accessors.

31
Q

what is an Indexer?

A

Indexer is a special kind of property that allows accessing elements of a list by an index. - If a class has the semantics of a list, or collection, we can define an indexer property for it. This way it’s easier to get or set items in the collection.

-see image (cookie [“name”]= “mosh”;

is indexer

32
Q

What is class coupling?

A

Class coupling is a measure of the dependencies a class has on other classes. This dependency is measured through parameters, method calls and interface implementations, just to name a few. The higher this number, the more likely a change in one class will affect other classes.

33
Q

what’s the problems with Inheritance?

A

see attached

34
Q

Name the 5 access modifiers

A

see attached

35
Q
A