C# Flashcards

1
Q

_______ means “many forms”, and it occurs when we have many classes that are related to each other by inheritance. Inheritance lets us inherit attributes and methods from another class. ________ uses those methods to perform different tasks.

A

Polymorphism

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

May or may not include ______ methods. Also cannot be instantiated, but they can be subclasses. A method declared without an implementation. If a class includes_____ methods, then the class itself must be declared ______?

A

Abstract Methods and Classes

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

Abstract type that contains a collection of methods and constant variables. It is one of the core concepts in java, and used to achieve abstraction, polymorphism and multiple inheritances.

A

Interfaces

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

Two or more methods may have the same name if they differ in parameters(different number of parameters, different types of parameters, or both). These methods are called overloaded methods and this feature is called method ______?

A

Overloading

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

______ occurs when a subclass (child class) has the same method as the parent class. In other words, ______ occurs when a subclass provides a particular implementation of a method declared by one of its parent classes.

A

Overriding

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

This function or method type in an OOP language is used to override the behavior of the function or method in an inherited class with the same signature to achieve the polymorphism.

A

Virtual Method

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

ways of parameter passing, one way doesn’t require initialization.

A

out, in, ref

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

Is a concept that acquires the properties from one class to other classes; for example, the relationship between father and son. Is a process of acquiring all the behaviors of a parent object.

A

Inheritance

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

A _____ between two objects associated with each other exists when there is a strong relationship between one class and another. Other classes cannot exist without the owner or parent class.

A

Composition

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

Is a keyword for creating a structure that contains variables, methods, different types of constructors, operators, etc. It is similar to classes that hold different types of data and has a value type. It creates objects which require less memory.

A

Struct

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

A template definition of the methods and variables in a particular kind of object. Thus, an object is a specific instance of this. Is one of the defining ideas of object-oriented programming.

A

Class

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

Is a method that is not bound to an identifier. Often used as arguments being passed to higher-order functions or used for constructing the result of a higher-order function that needs a return method.

A

Anonymous Method

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

Simply passing a duty off to someone or something else. Can be an alternative to inheritance. Means you use an object of another class an an instance variable, and forwards messages to the instance.

A

Delegates

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

Used for the export of variables, methods, and resources by name.

A

DLL(Dynamic Link Library)

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

managed .NET assemblies created using third-party tools and usually contains .NET code that can only access .NET supported libraries.

A

Managed plugins

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

platform-specific native code libraries. They are used to access third-party code libraries that would normally not be available to Unity otherwise.

A

Native plugins

17
Q

Can threads be used to modify a texture on runtime?

A

No, texture and meshes are examples of elements stored in GPU memory and Unity doesn’t allow other threads, besides the main one, to make modifications on these kinds of data.

18
Q

can threads be used to move a GameObject in the scene?

A

no, fetching the transform reference isn’t thread safe in Unity.

19
Q
class RandomGenerator : MonoBehaviour
{
    public float[] randomList;
    void Start()
    {
        randomList = new float[1000000];
    }
    void Generate()
    {
        System.Random rnd = new System.Random();
        for(int i=0;i
A
class RandomGenerator : MonoBehaviour
{
    public float[] randomList;
    void Start()
    {
        randomList = new float[1000000];
        Thread t = new Thread(delegate()
        {
            while(true)
            {
                Generate();
                Thread.Sleep(16); // trigger the loop to run roughly every 60th of a second
            }            
        });
        t.Start();
    }
    void Generate()
    {
      System.Random rnd = new System.Random();
      for(int i=0;i
20
Q

Define primitive data types?

A

Primitive data types are predefined data types such as byte, sbyte, int, uint, short, ushort, long, ulong, float, double, char, bool, object, string, decimal.

21
Q

What is unsigned vs signed variables?

A

only numerical variables have signed vs unsigned types. Unsigned is 0 to max. Signed is -min to -max.

22
Q

what are non-primitive data types?

A

non-primitive data types are user-defined data types such as enum, class, etc.

23
Q

Explain the difference between an object and a structure?

A

Generally speaking, objects bring the full object oriented functionality (methods, data, virtual functions, inheritance, etc, etc) whereas structs are just organized memory. Structs may or may not have support for methods / functions, but they generally won’t support inheritance and other full OOP features.

24
Q

Are you familiar with 3D math well enough to answer questions about it? If they ask you simple vector math questions like how to find the direction from vector A to Vector B could you answer that?

A

To find the vector between point A and point B, merely subtract the two vectors to get an angled vector pointing between the two points.

25
Q

Define an array with random values, then have it sort incrementally and decrementally.

A
int[] intArray = new int[] { 9, 2, 4, 3, 1, 5 };
//print array
Array.Sort(intArray);
//print array
Array.Reverse(intArray);
//print array
26
Q

How would you return the sum of a large collection of ints?

A

Use a long 64-bit value.

27
Q

what is wrong with an if statement like this?

if (computeRelVelocity(a, b) && needToCheck)

This lets me know if someone understands basic evaluation…

A
28
Q

How to instantiate a class in C#?

A

Use the new operator to instantiate a class in C#.

Let’s say our class is Line. Instantiation will create a new object as shown below −

Line line = new Line();

Using the object, you can now call the method −

line.setLength(6.0);

Let us see the example −

Example

using System;

namespace LineApplication {
   class Line {
      private double length; // Length of a line
      public Line() {
         Console.WriteLine("Object is being created");
      }
      public void setLength( double len ) {
         length = len;
      }
      public double getLength() {
         return length;
      }
      static void Main(string[] args) {
         Line line = new Line();
         // set line length
         line.setLength(6.0);
         Console.WriteLine("Length of line : {0}", line.getLength());
      }
   }
}
29
Q

What is the difference in reference types vs values types c#?

A
  • A Value Type holds the data within its own memory allocation on the stack.
  • A Reference Type contains a pointer to another memory location that holds the real data on the heap.
30
Q

This happens when you perform an operation with a data type and the result of this operation exceeds the size of a storage for this datatype. For example, when you add two large 32-bit integers together and the result cannot fit into Int32?

A

Arithmetic overflow