You are on page 1of 3

Viva Questions

1. What is C#?
C# is pronounced "C-Sharp". It is an object-oriented programming language created by
Microsoft that runs on the .NET Framework.
2. Which company developed the .NET software
Microsoft
3. What is the main function of CLR (Common Language Runtime)
Convert the managed code into native code and then execute the code.
4. What does MSIL (MicroSoft Intermediate Language) consist of
Consists of CPU and platform-independent set of instructions, which can be easily converted
to native code
5. Can multiple catch blocks be executed?
No, you cannot execute multiple catch blocks of the same type.
6. What is an object?
An object is a class instance that can be used to access class methods. The "new" keyword can
be used to construct an object.
7. What are Jagged Arrays?
A jagged array is an array whose elements are arrays, possibly of different sizes. A jagged
array is also called an "array of arrays."
8. Define Constructors.
A constructor is a member function with the same name as its class. The constructor is
automatically invoked when an object is created. While the class is being initialized, it
constructs all the values of data members.
9. Differentiate between Break and Continue Statement.
Continue statement - Used in jumping over a particular iteration and getting into the next
iteration of the loop.
Break statement - Used to skip the next statements of the current iteration and come out of the
loop.
10. What are the different types of commenting in C#
• /// example of XML comment
• // example of single-line comment
• /* example of a
multiline
comment */
11. Explain the four steps involved in the C# code compilation.
• Source code compilation in managed code.
• Newly created code is clubbed with assembly code.
• The Common Language Runtime (CLR) is loaded.
• Assembly execution is done through CLR.

Dept. of CSE, RVITM C# Programming Laboratory (21CSL582) 1


12. What is an Abstract Class?
Abstract class is a restricted class that cannot be used to create objects (to access it, it must be
inherited from another class).
13. What are reference types and value types?
A value type holds a data value inside its memory space. Reference type, on the other hand,
keeps the object’s address where the value is stored. It is, essentially, a pointer to a different
memory location.
14. What is the benefit of ‘using’ statement in C#?
The ‘using’ statement can be used in order to obtain resource for processing and defines a scope
at the end of which it is automatically disposed.
15. How do you inherit a class into another class in C#?
In C#, colon can be used as an inheritance operator. You need to place a colon and follow it
with the class name.
16. What is a Console application?
An application that is able to run in the command prompt window is called a console
application.
17. What is a Virtual Method in C#?
In the parent class, a virtual method is declared that can be overridden in the child class. We
construct a virtual method in the base class using the virtual keyword, and that function is
overridden in the derived class with the Override keyword.
18. Why can’t a private virtual methods in C# be overridden?
Private virtual methods are not accessible outside of the class.
19. What do you understand about Get and Set properties?
In C#, Get and Set are termed accessors because they use properties. Such private fields are
accessed via accessors.
20. What are the File Handling operations you can perform in C#?
File handling includes operations such as creating the file, reading from the file, and appending
the file, among others
21. How do you declare a 2D array in C# ?
int[ , ] x = new int [2, 3];
22. What is operator overloading C# ?
Operator overloading gives the ability to use the same operator to do various operations. It
provides additional capabilities to C# operators when they are applied to user-defined data
types.
23. Explain polymorphism in C#
Polymorphism means "many forms", and it occurs when we have many classes that are related
to each other by inheritance. Like we specified in the previous chapter; Inheritance lets us
inherit fields and methods from another class. Polymorphism uses those methods to perform
different tasks.

Dept. of CSE, RVITM C# Programming Laboratory (21CSL582) 2


24. Why do we need exception handling in C#?
To stop the abnormal termination of the program.
To provide user understandable messages when an exception is raised
25. What is the purpose of try catch C#?
The try statement allows you to define a block of code to be tested for errors while it is being
executed.
The catch statement allows you to define a block of code to be executed, if an error occurs in
the try block.
26. Explain the (four) Conditional Loops in C#
C# provides 4 loops that allow you to execute a block of code repeatedly until a certain
condition is met; they are:
• For Loop
• While loop
• Do ... While Loop
• Foreach Loop
Each and every loop requires the following 3 things in common:
• Initialization: that sets a starting point of the loop
• Condition: that sets an ending point of the loop
• Iteration: that provides each level, either in the forward or backward direction

Dept. of CSE, RVITM C# Programming Laboratory (21CSL582) 3

You might also like