TRANSCRIPTEnglish

Top C# Interview Questions And Answers | C# Interview Preparation | C# Training | Simplilearn

37m 10s6,014 words987 segmentsEnglish

FULL TRANSCRIPT

0:09

if you wanted to learn how to answer c

0:11

sharp interview questions then you have

0:13

come to the right place hey everyone

0:16

welcome to our simply learns youtube

0:17

channel today we'll talk about one of

0:19

the exciting topics in c sharp that is c

0:22

sharp interview questions and answers

0:25

but before we begin let me tell you guys

0:27

that we have daily updates on multiple

0:28

technologies so if you're a tech geek in

0:31

a continuous hunt for latest

0:32

technological trends then consider

0:34

getting subscribed to our youtube

0:35

channel and don't forget to hit that

0:37

bell icon to never miss an update from

0:39

simply learn

0:40

this tutorial video has 50 interview

0:42

questions and all these questions are

0:44

divided into three levels beginner

0:47

intermediate and advanced levels so

0:49

without further ado let's get started

0:51

with the first topic

0:54

now before getting into any interview

0:56

questions i would like to reveal the

0:57

first type of questions that are

0:59

recording interview questions it is

1:01

obvious that in any technical interview

1:03

you will be asked to code some or the

1:05

other program so we have bought the most

1:07

frequently asked top five coding based

1:09

questions in c sharp which are write a

1:12

program in c sharp to reverse a string

1:14

write a program in c sharp to find if a

1:16

given string is a palindrome or not

1:18

write a c sharp program to find the

1:20

substring from a given string write a c

1:23

sharp program to find if a positive

1:24

integer is prime or not and lastly write

1:28

a singleton design pattern and how to

1:30

implement them in c sharp

1:32

so these are the most frequently asked

1:34

coding based interview questions based

1:36

on c sharp and if you want we would like

1:38

to share these quotes with you please

1:40

feel free to share us your email ids in

1:41

the comments section below so that we

1:43

can share you all these codes

1:45

now let's start with the beginner level

1:46

interview questions

1:49

so our first question is how the c

1:51

programming language differs from

1:53

c-sharp programming language the first

1:55

difference is that the c programming

1:56

language allows for procedural

1:58

programming whereas c-sharp programming

2:01

language provides object-oriented

2:02

programming the second difference is

2:05

that c programming language supports

2:07

pointers whereas in c sharp pointers are

2:10

only used in unsafe mode the third

2:13

difference between c and c sharp is that

2:16

garbage collection is not supported in c

2:18

whereas in c sharp garbage collection is

2:21

handled by the common language runtime

2:23

or clr

2:25

the next difference between the both is

2:26

the c programming language is cross

2:28

platform in contrast the dot net

2:31

framework is required to run on the

2:33

c-sharp language only fifth difference

2:36

between c and c sharp is we can achieve

2:39

a low level of abstraction using c

2:41

programming language whereas in c sharp

2:44

we can achieve a high level abstraction

2:47

the last difference between the both is

2:49

the c programming language is primarily

2:51

used in commercial industries and

2:52

engineering whereas c sharp on the other

2:54

hand is used for software development

2:56

and other network related goals

2:59

the second question is what is an object

3:01

and a class in c c-sharp

3:03

the answer for this question is a class

3:06

is a collection of properties and

3:07

methods used to represent a real-time

3:09

entity it is data structure that groups

3:11

all the instances into a single unit

3:14

whereas an object of a class is defined

3:16

as an instance technically it is simply

3:19

a block of memory that can be stored as

3:21

variables arrays or collections for

3:24

example the car is working as a class on

3:27

my screen and the objects are ford and

3:30

rd which are the car manufacturers

3:34

next is what are the fundamentals of

3:36

object-oriented programming

3:39

the answer for this question is the

3:40

object-oriented programming language or

3:43

oops in c-sharp is divided into four

3:45

concepts that is encapsulation

3:48

abstraction

3:50

inheritance and polymorphism

3:54

let's take a closer look at each of the

3:56

four object oriented programming

3:58

concepts first encapsulation

4:00

encapsulation is defined as when an

4:03

object's internal representation is

4:04

hidden from the view outside its

4:06

definition it is said to be encapsulated

4:08

only the necessary information is

4:10

accessible while the rest of the data

4:12

implementation is hidden

4:14

next abstraction abstraction is the

4:17

process of identifying and eliminating

4:19

irrelevant details from the object's

4:21

critical behavior and data

4:23

following the oops concept inheritance

4:26

is the ability to create new classes

4:28

from existing ones it is accomplished by

4:30

gaining access to altering and extending

4:33

the behavior of objects in the parent

4:36

class

4:36

lastly we have polymorphism polymorphism

4:39

is defined as a name that means one name

4:43

many forms it is accomplished using

4:45

several methods with the same name but

4:47

different implementations

4:49

now we have the next question that is

4:52

what is the common language runtime or

4:55

clr so the answer for this question is

4:57

the common language runtime manages the

4:59

execution of dotnet programs clr the

5:03

just-in-time compiler translates

5:04

compiled code into machine instructions

5:07

this is the program that the computer

5:09

runs clr provides memory management

5:12

exception handling type safety and other

5:14

services now let's look at the next

5:17

question

5:18

what is managed and unmanaged code

5:22

so manage code is executed by clr common

5:25

language runtime on which all

5:26

application code is based the internet

5:29

platform because of this is regarded as

5:31

managed internally the dotnet framework

5:34

uses the garbage collector to clear

5:35

unused memory whereas unmanaged code is

5:38

any code executed by an application

5:40

runtime in a framework other than dotnet

5:43

the application runtime will handle

5:45

memory security and other performance

5:47

operations

5:48

next we have

5:50

what exactly is an interface

5:53

in c sharp an interface is a class

5:55

blueprint it is like an abstract class

5:57

and that all the methods declared within

5:59

the interface are abstract

6:01

it cannot have a method in body and

6:03

cannot be instantiated instead it can be

6:06

used to achieve multiple inheritances

6:09

that can't reach

6:10

the following example demonstrates an

6:12

odd even class has access to both the

6:15

even and odd classes

6:17

now we have the next question

6:19

what are the different types of classes

6:21

in c sharp so the answer for this

6:23

question is there are four different

6:25

types of classes in c sharp the first is

6:28

partial class which states that its

6:30

members can be divided or shared across

6:32

multiple files the keyword partial

6:35

denotes it

6:36

the second class is abstract an abstract

6:38

class is one was object cannot be

6:41

instantiated the only way to get the

6:43

class is to inherit it must include at

6:46

least one method the keyword abstract

6:48

denotes the abstract classes the next

6:50

class is sealed class a sealed class

6:53

cannot be inherited to access a sealed

6:56

class members we must create a classes

6:59

object then the keyword seal denotes it

7:02

the last and the fourth class in c sharp

7:04

is static this class does not allow

7:06

inheritance the classes members are also

7:09

static the keyword static denotes this

7:12

type of class the keyword instructs the

7:14

compiler to look for any static class

7:16

instances created by accident

7:19

now the ninth question

7:21

what is the difference between equality

7:23

operator and equals method in c sharp

7:26

the difference between the equality

7:28

operator which is double equals to and

7:31

equals method in c sharp is the the

7:34

double equals operator and the equals

7:36

method compare two values or reference

7:38

type data items

7:40

this answer explains the fundamental

7:42

distinction between two the comparison

7:44

operator is the equality operator and

7:47

the equals method compares the contents

7:49

of the string the double equals to

7:51

operator compares the identity of

7:53

reference whereas the equals method

7:55

compares the only reference

7:57

now we have the tenth question

8:01

explain code compilation in c sharp

8:06

the answer for this question is in c

8:09

sharp code compilation consists of three

8:11

steps the c-sharp compiler compiles the

8:14

source code into managed code putting

8:16

the newly created code together into

8:18

assemblies

8:19

then the common language runtime is

8:21

being loaded and clr is carrying out the

8:24

assembly

8:25

now we have the 11th question what are

8:27

the differences between a class and

8:29

struct

8:30

the answer for this question is

8:32

the first difference is class can

8:35

inherit whereas struct cannot the second

8:38

difference is a class is passed by

8:40

reference type whereas struct is passed

8:42

by value type

8:45

the next difference is class members are

8:47

private by default whereas in struct

8:50

members are public by default

8:52

the fourth difference is class is

8:54

appropriate for large complex operations

8:56

and objects though struct is appropriate

8:58

for small isolated models the last

9:01

difference between the boat is we can

9:03

use a garbage collector to manage memory

9:05

in class whereas a struct cannot use

9:08

garbage collector and thus cannot manage

9:10

memory

9:11

the next question is what is the

9:12

difference between virtual method and

9:14

abstract method

9:16

virtual method is default implementation

9:19

of virtual process is always required it

9:23

can however be overridden in the derived

9:25

class though this is not required for

9:27

example the override keyword can be used

9:30

to override it

9:32

though an abstract method has no

9:34

implementation it belongs to the

9:36

abstract class therefore derived class

9:38

must implement the abstract form

9:40

although an override keyword is not

9:42

required in this case it can be used

9:46

now the 13th question explain namespaces

9:49

in c sharp

9:50

namespaces are employed in organization

9:52

of large code projects for example in c

9:55

sharp the most common namespace is

9:57

system we can create our namespaces and

10:00

use one namespace with another known as

10:03

nested namespaces the keyword namespace

10:06

is used to identify them

10:08

following the c-sharp interview

10:10

questions and answers the next question

10:12

is what is the using statement the

10:15

answer for this question is the using

10:16

keyword indicates the program uses the

10:19

specified namespace as an example

10:22

consider system the system is a

10:24

namespace in this context

10:27

the class console is defined in the

10:29

system module so in our program we can

10:31

use a console write line and read line

10:34

now the next question is explain

10:37

abstraction

10:38

one of the object oriented concepts is

10:40

abstraction it is used to display only

10:42

the classes essential features and hide

10:44

unnecessary information

10:46

let us use a car for an example

10:49

a car driver should be familiar with the

10:51

vehicle's details such as color name

10:53

mirror steering gear brake and so on he

10:56

doesn't need to know about the internal

10:58

combustion engine and an exhaust system

11:01

as a result abstraction aids in knowing

11:03

what is required and concealing internal

11:06

details from the outside internal

11:08

information can be hidden by declaring

11:10

such as parameters as private and using

11:13

the private keyword

11:14

the following question is explain

11:16

polymorphism polymorphism in programming

11:18

means the same method but different

11:20

implementations it is classified into

11:23

two types compile time polymorphism and

11:26

runtime polymorphism the compile-time

11:28

polymorphism results the call in

11:30

compile-time polymorphism is also

11:32

referred to as static binding early

11:34

binding and overloading

11:37

the compiler does not resolve the

11:38

runtime polymorphism call and is also

11:41

referred to as dynamic binding late

11:43

binding or overriding

11:45

for example a man acts as a father a

11:48

husband and an employee all

11:51

simultaneously the next question

11:54

how is exception handling implemented in

11:56

c sharp in c sharp exception handling is

11:59

accomplished using four keywords try

12:02

catch finally and through

12:04

in try try contains a block of code that

12:07

will be checked for exceptions in catch

12:10

a program that catches an exception with

12:12

the help of the exception handler and

12:14

finally it is a block of code written to

12:17

run regardless of whether an exception

12:19

is scored or not and finally through

12:21

throw is when a problem occurs it throws

12:23

an exception

12:25

followed by exception handling we have

12:27

another question

12:28

that is what are the c sharp input and

12:31

output classes what are commonly used

12:33

for input and output classes

12:35

the system.io namespace in c sharp

12:37

contains classes used to perform various

12:39

operations on files such as creating

12:41

deleting opening closing etc

12:44

the following are some of the examples

12:46

of commonly used input output classes

12:48

which are file stream writer stream

12:51

reader string writer string reader part

12:53

etc

12:55

file aids to with the manipulation of a

12:57

file

12:58

stream writer is the class that is used

13:00

to write characters to a string

13:03

the stream reader is used to read

13:05

characters from stream the string writer

13:08

is used to write a string buffer the

13:09

string reader is used to read the string

13:11

buffer the path is used to perform

13:14

operations on path information followed

13:16

by that the next question is what is

13:18

stream reader or stream writer class the

13:21

answer for this question is

13:23

the name space system dot input output

13:25

contains the classes stream radar stream

13:27

writer which are used to read and write

13:29

character 90 database data

13:31

members of stream reader are close read

13:34

and read line members of stream writer

13:36

are close right and right line

13:39

there is an example on my screen where

13:41

you have code block to read and

13:44

a code block to write using stream

13:45

reader and stream writer now the next

13:49

question what is a destructor in

13:51

seashore destructor are used to clear

13:53

memory and free resources in c sharp

13:56

however this is handled by a garbage

13:58

collector on its own internally system

14:00

dot gc dot collect is used to clean up

14:03

but it may be necessary to implement

14:05

destructors in some classes manually

14:10

the following is an example of vehicle

14:12

acting as a destructor using the tide

14:14

symbol following the 20th question we

14:17

have the 21st question which says what

14:20

is an abstract class

14:23

so the answer for this question is an

14:25

abstract class is denoted by the

14:26

abstract keyword and only be used as a

14:29

base class this class should always be

14:31

inherited it is impossible to create an

14:33

instance of the class itself if we don't

14:36

want any program to create an object of

14:38

a class we can make it as categories

14:41

abstract there are no implementations of

14:43

any methods in the abstract class they

14:45

must be implemented in the child class

14:48

here's an example that shows an abstract

14:50

as abs then the child as child class

14:54

that inherits the abs abstract class and

14:57

finally an object as c is one of the

14:59

accesses

15:01

the addition function via a new process

15:03

called submission

15:05

and abstract classes methods are all

15:07

implicitly virtual as a result the

15:10

virtual keyword should not be used with

15:12

any abstract classes methods they must

15:15

however be implemented in the child

15:17

class the next question is what is the

15:19

difference between boxing and unboxing

15:21

codes

15:23

boxing is converting a value type to a

15:26

reference type at the same time unboxing

15:28

is the explicit conversion of the same

15:30

reference type back to the value type

15:33

the following is an example val 1 is 50

15:36

which is going through boxing process

15:37

and val 1 is converted into object

15:41

boxing val which is then converted back

15:43

into an unboxing variable after the

15:46

boxing process

15:47

the following question is what is the

15:49

difference between continue and break

15:51

statement the break statement terminates

15:53

the loop it causes the program control

15:56

to exit the loop in contrast the

15:58

continue statement instructs the

16:00

program's power to go only to the

16:03

current iteration however it does not

16:05

affect the loop

16:07

following is an example for break

16:09

statement in which the break keyword is

16:11

used to terminate the loop going from 0

16:13

to 10 immediately the continue block of

16:16

code is used to skip the current

16:18

iteration of 2. the final question for

16:20

the beginner level is what is difference

16:23

between final finally and finalized

16:25

blocks

16:27

final is a keyword that indicates that a

16:30

variable method or a class is

16:32

unchangeable to put it simply finally

16:36

like try and catch blocks it is used for

16:39

exception handling the final block is

16:41

always executed regardless of whether an

16:44

exception is raised

16:45

this block is mainly used to close

16:47

database connections input output

16:49

resources etc lastly the finalized

16:52

method in java.lang protected method

16:54

object type it is passed down to every

16:56

java class you create therefore the

16:58

garbage collector thread calls this

17:00

method before removing an object from

17:02

memory now we have reached the

17:05

intermediate level

17:06

the 25th question on our list is what

17:10

exactly is an array so the answer for

17:12

this question is an array is a data

17:14

structure that stores multiple variables

17:16

of the same data type it is a set of

17:18

variables stored in a single memory

17:20

location here's an example of marks

17:23

array with 5 integer values 10 20 30 40

17:27

and 50. a single dimensional array is a

17:30

linear array that stores variables in a

17:32

single row the preceding example is a

17:35

one-dimensional array arrays can have

17:37

multiple dimensions rectangular arrays

17:39

are another name for multi-dimensional

17:41

arrays we have a multi-dimensional array

17:44

as numbers with three rows and three

17:46

columns with one two and three in the

17:49

first row three four and five in the

17:51

second row and four five and six in the

17:53

third row

17:55

now the next question is what is a jack

17:58

arry

17:59

a jagged array is an array with array

18:01

elements it is also known as an array of

18:04

arrays and can have a single dimension

18:06

or multiple dimensions here's an example

18:09

of jack arry a jagged array with four

18:12

rows

18:13

in the first row we have two values one

18:16

and two the next row contains values

18:18

three four and five and six the third

18:21

row includes three values seven eight

18:23

and nine and the fourth row contains

18:26

five values that is three four five six

18:29

and seven

18:30

now the next question name some

18:32

properties of arrays

18:34

an array has following properties that

18:37

is length this function returns the

18:39

total number of elements in an irene

18:41

size

18:42

this indicates whether the array's

18:43

length is fixed or not

18:45

read-only this indicates whether the

18:47

array is read-only or not

18:50

now we have 28th question

18:52

what is an array class

18:54

arrays can be created manipulated

18:56

searched for and sorted using array

18:59

class however the array class does not

19:02

belong to the system however the

19:04

collection's namespace is still

19:06

considered because it implements the

19:08

list interface therefore the ira class

19:10

serves as the foundation for area

19:12

supporting language implementations

19:15

we have an array class called colors and

19:18

we have four colors red blue green and

19:21

yellow we print those colors in this

19:23

array class example

19:25

now the next question is what exactly is

19:27

a string what are the characters of

19:29

string class a string is the grouped

19:31

character objects string variables that

19:34

can be declared in c sharp a string

19:36

class in c sharp represents a string in

19:38

the following example we have a string

19:40

called name that is inserted by c sharp

19:44

interview questions and answers the

19:46

string class has the following

19:47

properties

19:49

character returns the current strings

19:51

character object the length function

19:52

returns the number of objects in this

19:54

current string

19:56

another 30th question

19:58

what is an escape sequence named some

20:01

strings escape sequences in c sharp in c

20:03

sharp a backslash indicates the escape

20:06

sequence the backslash indicates that

20:09

the character should be interpreted

20:11

literally or unique

20:13

an escape sequence is treated as if

20:15

there were a single character first we

20:18

have backslash n which means newline

20:21

character next we have backslash b which

20:24

is used for backspace then we have two

20:26

types of backslash which represents

20:29

backslash itself after that we have a

20:31

single backslash code and lastly we have

20:34

backslash double quote now the 31st

20:37

question

20:38

what are regular expressions search a

20:41

string using regular expressions

20:43

a regular expression is a template that

20:45

can match a set of input operators

20:47

constructs and character laterals can

20:50

all be used in the pattern for example

20:52

regex is used for string passing and

20:55

character string replacement an example

20:57

occurs 0 or more times before the

21:00

preceding character as a result

21:02

a star b predicts is equivalent to b

21:06

comma a b comma a a b comma a aap and so

21:10

on

21:11

following is the code language program

21:13

in which we have strings as c c plus

21:16

plus and c sharp then we have c l as an

21:20

object and try to find the string c

21:22

sharp as we can see c sharp is present

21:25

in the following string so we will print

21:27

as a match as found now the next

21:30

question what are the fundamental string

21:32

operations explain the following are

21:34

some examples of basic string operations

21:37

the first operation is concatenate a

21:40

system can concatenate two strings

21:42

string concatenate or use the plus

21:45

operator the next string operation is we

21:48

have modify replace x comma y is the

21:51

function that replaces one string with

21:53

another the trim function is used to cut

21:56

a string at the end or beginning third

21:58

string operation is compare operation

22:01

system dot string comparison is used to

22:03

compare two strings either case

22:04

sensitively or not at all it requires

22:07

two parameters the original string and

22:09

the string to be compared with the last

22:11

operation is a search operation used to

22:13

find specific string using the start

22:16

with and ends with methods

22:18

following question is what exactly is

22:20

passing how do you pass a date and time

22:23

string the answer with this question is

22:25

parsing is a process of converting a

22:27

string into another data type for

22:29

example consider the string value 100

22:31

which we are attempting to convert into

22:33

a number variable of integer data type

22:35

using pass function

22:37

as a result the pass method

22:40

converts string 100 into its base type

22:43

that is integer

22:44

following the same method to convert

22:46

date time string string date time is

22:48

equals to date july 24 2011.

22:52

datetime past while is equals to date

22:54

time and past method

22:56

date time

22:58

we will now move into the advanced level

23:00

interview questions

23:02

now the first one in advanced level

23:04

interview question is what is a delegate

23:06

explain

23:07

a delicate is a variable that holds the

23:09

reference to a method hence it is a

23:12

function pointer or reference type all

23:14

delegates are derived from

23:15

system.delegate namespace both delegate

23:18

and the technique that it refers can

23:20

have the same signature

23:22

declaring a delegate public delegate

23:24

void some numbers and number following a

23:27

delegate's declaration the

23:29

representative must create the object

23:31

using new keyword

23:33

some numbers sn1 is equals to some new

23:36

numbers of number the delegate acts as

23:38

an encapsulation for the reference

23:40

method which is called internally when a

23:42

delegate is called now the next question

23:45

how to use delegates with events

23:48

delegated authority is used to initiate

23:51

and manage events a delegate must always

23:54

particular at first following by the

23:56

events

23:57

this diagram gives three functions to

23:59

delete and the delegate to generate an

24:01

event that is an event generator

24:05

the next question is what are events

24:08

events are user actions that cause the

24:10

application to receive notifications to

24:12

which it must respond user actions can

24:15

include mouse movements keypress and so

24:18

on

24:19

a class that raises an event is known as

24:22

the publisher and the class that

24:23

responds or receives the event is known

24:25

as a subscriber

24:27

if an event does not have one subscriber

24:29

it is never raised events are declared

24:32

using delegates

24:34

in this example we have delegates as

24:36

print and os and event names as my event

24:39

1.

24:41

now the next question is what are the

24:43

different types of delegates and there

24:46

are three types of delegates the first

24:48

one is single delegate a single delegate

24:50

is a delegate that can only call one

24:52

method

24:54

the second type of delegate is the

24:55

multicast delegate a delegate that can

24:57

call multiple methods is known as a

24:59

multicast delegate the plus and minus

25:01

operators are used to subscribe and

25:03

unsubscribe the third type of delegate

25:05

is the generic delegate it does not

25:07

require a definition of an instance and

25:09

it is classified into three types that

25:10

is action function and

25:12

predicate

25:14

so the action is in the preceding

25:16

example of delegates the events we can

25:18

use the action keyword to replace the

25:20

definitions of delegate and even

25:22

function a function delegate defines a

25:24

method that can take arguments and

25:26

results and lastly we have predicate a

25:29

method that can be called with arguments

25:31

and always returns a bool

25:33

now followed by that we have the 38th

25:36

question

25:37

what do multicast delegates mean

25:41

the answer for this question is in c

25:43

sharp multicast delicate is a delegate

25:45

that holds the references to a multiple

25:47

functions when we invoke the multicast

25:50

delegate we gather all the tasks that

25:52

the delegate prefers for example if you

25:55

want to use a delegate to call multiple

25:57

methods all the method signatures must

25:59

be seen let's see a code example to

26:01

multicast delegate

26:04

this program uses a namespace delegate

26:06

and then declares delegate as a

26:08

multi-delegate with formal arguments a

26:10

and b

26:11

we define the addition and subtraction

26:13

functions in the class program which we

26:15

declare and calculate as class b and a

26:19

minus b respectively then in the main

26:22

function we create a class program

26:23

object p1 then we declare md1 and md2

26:26

objects for addition and subtraction

26:28

operations

26:29

then we assign md1 to md1 and md2 giving

26:32

a value of 100 to a and a value of 200

26:35

to b

26:37

now let's try to execute the program and

26:38

see the output

26:48

now the next question is what are

26:49

synchronous and asynchronous operations

26:52

so the answer for this question is

26:54

synchronization is a technique for

26:55

writing thread safe code in which only

26:58

one thread can access a resource at any

27:00

given time before continuing with the

27:02

program flow the asynchronous call waits

27:04

for the method to complete in

27:06

asynchronous mode the method calls

27:08

return immediately so that the program

27:10

can perform other operations while the

27:12

called method completes its work the

27:15

async and await keywords are used to

27:17

achieve asynchronous programming in c

27:19

sharp

27:20

our next question is what exactly is

27:22

reflection in c sharp reflection is the

27:25

ability of a code to access the

27:26

assemblies metadata during runtime a

27:29

program reflects itself and uses

27:32

metadata to inform or change its

27:33

behavior

27:35

system of namespace reflection includes

27:37

methods and classes for managing the

27:39

information of all loaded types and

27:41

techniques it is primarily used in

27:43

windows applications such as viewing the

27:45

properties of a button in a windows form

27:47

the class reflection members inform

27:49

object is used to discover the

27:51

attributes associated with the class

27:53

following that we have reached the next

27:55

question that is the 41st question what

27:57

is the generic class

27:59

generics is also known as gender classes

28:01

create courses or objects with no

28:03

specific data type for example the data

28:06

type can be assigned in runtime that is

28:09

the program uses it

28:11

let's see a simple code for generic

28:13

class

28:15

in this program we have name space as

28:17

generic class public class test class

28:19

and g to represent the generic class

28:21

after that we define an array namely

28:23

object 1 of generic type with length 5

28:26

then we have int variable as count 1

28:29

then we have a function as some adding

28:31

items mechanism into a generic type next

28:34

we have to keep adding items to an array

28:36

until the count plus one is less than

28:38

six then we have to keep increasing the

28:40

count value by one following that we

28:42

have an index variable for each

28:44

statement iteration in which we have to

28:47

get and set properties the get property

28:49

is used to return the index value and

28:51

the set property is used to set a value

28:53

with the same name as the index value

28:56

finally we instantiate a generic with an

28:58

integer with the object name int obj in

29:01

the main method then we add integer

29:03

values to the array and finally we

29:05

multiply all the values in the array

29:08

now let's try to execute this code and

29:09

see the output

29:11

now the program got successfully

29:12

executed and you can see the output

29:14

right on my screen

29:16

now the next question explain get and

29:18

set access properties

29:20

get and set are referred to accesses

29:22

properties make to use these the

29:24

property implements a mechanism for

29:26

reading and writing the value of a

29:28

private field these accesses are used to

29:30

gain access to a private field the get

29:32

property method is used to retrieve the

29:34

value of a property to change the value

29:37

use set property accessor and let's see

29:39

an example to understand this in a much

29:42

better way

29:43

we have a class name as a person name in

29:45

this program followed by two variants

29:47

firstly we have a private variable as n

29:50

for the person's name then we have

29:51

public variable

29:53

as name one we have get property that

29:55

returns variable n and finally we have a

29:57

set property that assigns variable m to

29:59

the variable value next the value

30:02

keyword denotes the value that we

30:03

transfer to the property n next in the

30:06

main function we have an object name as

30:08

my name where we give the name as abc

30:10

and finally we display the person's name

30:12

as abc

30:13

now the output is on my screen right

30:16

over here

30:18

now let's get back to the ppt

30:20

the next question is what exactly is a

30:22

thread

30:23

and what is multi-threading a thread is

30:25

a collection of instructions that can be

30:27

executed to allow our program to perform

30:29

concurrent processing confident

30:30

processing will enable us to perform

30:32

multiple operations at the same time

30:34

c-sharp has a thread by default however

30:37

the other threads can be created to run

30:39

code in parallel with the original code

30:41

this is accomplished by having different

30:44

threads handle different process

30:45

referred to as multi-threading to handle

30:47

multi-threaded operations several thread

30:49

methods are used start sleep about

30:51

suspend resume and join are all options

30:54

the next question is name some

30:56

properties of thread class

30:58

some of the properties of thread class

31:00

are first we have is alive property

31:02

it has work then when a thread is active

31:06

this value is actual

31:08

the following property is name which

31:10

returns the thread's name also can set

31:13

name for the thread following that we

31:14

have the next property as priority which

31:16

returns the prioritized value of this

31:18

task set by the operating system the

31:21

background is the following property of

31:23

thread class it gets or sets the value

31:25

that indicates whether a thread should

31:27

be a background process or a foreground

31:29

process last property is we have thread

31:32

state which describes the thread state

31:35

on the next question we have what are

31:37

the different states of a thread so the

31:40

different states of thread are

31:42

unstarted state which means a thread has

31:44

been created next we have running state

31:47

which means that the threat begins

31:49

execution weight sleep joint is the

31:51

third stage

31:52

in which a threat called sleep another

31:54

thread calls weight and another thread

31:56

calls join next we have suspense state

31:59

the thread has been halted about it is

32:01

the next state which the thread has died

32:04

but not being changed to the state

32:06

stopped

32:07

last is we have stop state which means

32:08

that this thread has come to a halt

32:11

followed by this we have the next

32:12

question which is what is a deadlock

32:15

a deadlock occurs when a process cannot

32:18

complete its execution because two or

32:20

more methods are awaiting the completion

32:22

of another

32:23

this is common in multi-threading

32:26

followed by that we have another

32:27

question explain lock monitors and mutex

32:30

object in multi-threading

32:32

a lock keyword ensures that only one

32:34

thread can enter a specific code section

32:37

at a time the preceding example lock ob

32:40

jx indicates that a lock placed on obx

32:43

until this process releases it at which

32:46

no point no other thread will be able to

32:49

access obj mutex is like lock but it can

32:52

work across multiple processes

32:54

simultaneously for example weight one

32:56

method is used to lock the lock and

32:59

release mutex is used to unlock it on

33:02

the other hand mutex is slower than lock

33:03

because it takes time to acquire and

33:06

release it monitor enter and observe

33:09

internally exits implements a lock a

33:11

lock is monitor shortcut internally and

33:14

lock objects is called you can see an

33:16

example right on my screen

33:18

the next question on the list is what is

33:20

race condition

33:21

a race condition occurs when two threads

33:23

access the same resource and attempt to

33:25

change it simultaneously it is

33:27

impossible to predict which thread will

33:29

be the first to access the resource if

33:31

we have two threads t1 and t2 both

33:33

attempt to access a shared resource

33:35

called x if both threads try to access

33:38

or write a value to x the last value

33:40

returned to x is saved

33:42

49th question in the list is what is

33:45

serialization and dc realization the

33:47

answer for this question is converting

33:48

code to binary format is known as

33:50

serialization once converted to budget

33:52

is simple to store and write to a disk

33:54

or other storage devices serialization

33:57

is most valuable when we don't want to

33:59

lose the original form of the code and

34:01

want to retrieve it at any time in the

34:02

future

34:03

dc realization refers to recovering

34:05

c-sharp code from binary form now the

34:08

50th question

34:10

what are the different types of

34:11

serialization now there are various

34:13

types of serialization which are as

34:15

follows

34:16

the first type of serialization is the

34:17

xml serialization the second one is soap

34:20

and the last and the third one is the

34:21

binary serialization

34:24

another 51st question what is an xsd

34:28

file

34:30

so an xsd file is an abbreviation for

34:32

xml schema definition it defines the

34:34

structure of an xml file it determines

34:36

which element should be represented in

34:38

the form of xml and in what order and

34:40

which property should be current

34:43

during serialization of c sharp code and

34:46

x sd.exe converts the classes into xsd

34:50

compiler form

34:52

now as discussed initially we will go

34:55

through some coding based interview

34:56

questions the document of code will be

34:59

sent to you feel free to write your

35:00

emails in the comment section below so

35:02

that we can respond to you at the

35:03

earliest

35:06

now program one is string reverse

35:10

so you can see that it is converting

35:12

simply learn into the reverse string

35:15

which is here

35:17

now let us go through the second program

35:18

real quick

35:20

now on my screen you can see the second

35:21

program the second program is based on

35:23

converting or checking if the string is

35:26

palindrome or not let's quickly execute

35:28

this

35:28

you can see that it is asking for enter

35:30

string

35:31

let us enter

35:35

p op pop

35:37

and it is saying as the string is apalan

35:39

rom now let us quickly execute the third

35:46

now the third one is based on substring

35:48

operations let's quickly execute the

35:50

code let's enter a string here simply

35:53

learn

35:56

so here you can see the substrings that

35:58

can be created using simply learn

36:01

now let's execute the fourth code so

36:03

this program is based on if checking the

36:05

number is prime or not

36:07

so now let's enter a number let's enter

36:10

7 which is a prime number which says

36:12

number is prime now the fifth question

36:14

is based on single ton

36:16

now let's try to execute this code and

36:17

see the output

36:20

now you can see the code got

36:20

successfully executed and the output is

36:22

over here hello and hi

36:24

now don't you worry about the code

36:26

please feel free to let us know your

36:27

email ids in the comments section below

36:29

and we will have this quote sent over to

36:31

you at the earliest

36:34

now with that we have come to an end of

36:35

this session on

36:36

c-sharp interview questions if you have

36:38

any queries regarding any of the topics

36:40

covered in this session or if you need

36:42

the code that we have executed in this

36:44

particular session then please feel free

36:45

to let us know in the comment section

36:46

below and our team of experts will be

36:48

happy to resolve all your queries until

36:50

next time thank you stay safe and keep

36:52

learning

36:58

hi there if you like this video

37:00

subscribe to the simply learn youtube

37:02

channel and click here to watch similar

37:04

videos to nerd up and get certified

37:07

click here

UNLOCK MORE

Sign up free to access premium features

INTERACTIVE VIEWER

Watch the video with synced subtitles, adjustable overlay, and full playback control.

SIGN UP FREE TO UNLOCK

AI SUMMARY

Get an instant AI-generated summary of the video content, key points, and takeaways.

SIGN UP FREE TO UNLOCK

TRANSLATE

Translate the transcript to 100+ languages with one click. Download in any format.

SIGN UP FREE TO UNLOCK

MIND MAP

Visualize the transcript as an interactive mind map. Understand structure at a glance.

SIGN UP FREE TO UNLOCK

CHAT WITH TRANSCRIPT

Ask questions about the video content. Get answers powered by AI directly from the transcript.

SIGN UP FREE TO UNLOCK

GET MORE FROM YOUR TRANSCRIPTS

Sign up for free and unlock interactive viewer, AI summaries, translations, mind maps, and more. No credit card required.