Site icon NOTE BAHADUR

DotNet Technology questions and some tips to study and revision

UNIT I 

Short Questions (5 Marks)

Q1. Define Object-Oriented Programming (OOP). Explain its four pillars.

Q2. What is Type Safety in C#?

Q3. Differentiate between Stack and Heap Memory.

Q4. Explain the role of the Garbage Collector (GC).

Q5. What is CLR? Mention its functions.

Q6. What is the Framework Class Library (FCL)?

Q7. What is .NET Standard 2.0?

Q8. List the applications of the .NET Framework.

Long Questions (10 Marks)

Q1. Explain the architecture of the .NET Framework with a neat diagram.

Q2. Describe the execution process of a C# program from source code to machine code.

Q3. Compare .NET Framework, .NET Core, Mono, Xamarin, and .NET MAUI.

Q4. Explain CLR and its services in detail.

Q5. Discuss the major components and applied technologies of the .NET Framework.

⭐ One-Night Revision Box (Unit I)

UNIT II 

Short Questions (5 Marks)

Q1. Write the structure of a C# program.

Q2. Differentiate between Console and GUI Applications.

Q3. Explain Identifiers and Keywords with examples.

Q4. Explain Comments in C#.

Q5. Explain Data Types with classification.

Q6. Differentiate between Value Types and Reference Types.

Q7. Explain Variables and Constants.

Q8. Explain Type Conversion (Implicit and Explicit).

Q9. Explain Operators in C#.

Q10. Differentiate between = and ==.

Q11. Explain Strings and Characters.

Q12. Explain Arrays with Examples.

Q13. Explain Parameter Passing Methods.

Q14. Explain Command-Line Arguments.

Q15. Explain Nullable Types.

Q16. Explain Boxing and Unboxing.

Long Questions (10 Marks)

Q1. Explain Selection Statements in C# with Syntax and Examples.

Q2. Explain Iteration Statements in C# with Syntax, Flowcharts, and Programs.

Q3. Compare for, while, do-while, and foreach.

Q4. Explain Jump Statements with Suitable Programs.

Q5. Explain Namespaces in C# with Syntax, Diagrams, and Suitable Programs.

Important Definitions

C# Program

A C# program is a collection of classes and methods that execute from the Main() method.

Identifier

An identifier is a user-defined name given to variables, methods, classes, namespaces, or other program elements.

Keyword

A keyword is a reserved word in C# with a predefined meaning and cannot normally be used as an identifier.

Variable

A variable is a named memory location used to store data whose value can change during program execution.

Constant

A constant is a fixed value declared using the const keyword that cannot be modified after initialization.

Data Type

A data type specifies the kind of value a variable can store and determines the operations that can be performed on it.

Type Conversion

Type conversion is the process of converting a value from one data type to another.

String

A string is a sequence of Unicode characters enclosed within double quotation marks (“).

Character

A character (char) stores a single Unicode character enclosed within single quotation marks (‘).

Array

An array is a collection of elements of the same data type stored in contiguous memory locations and accessed using an index.

Parameter

A parameter is a variable used to receive values passed to a method.

Selection Statement

A selection statement controls program execution by choosing one block of code from multiple alternatives based on a condition.

Iteration Statement

An iteration statement repeatedly executes a block of code while a specified condition is satisfied.

Jump Statement

A jump statement transfers program control from one location to another.

Namespace

A namespace is a logical container used to organize related classes, interfaces, structures, delegates, and other types while preventing naming conflicts.

Important Syntax

Variable Declaration

int age = 20;

double salary = 50000;

Constant

const double PI = 3.14159;

Implicit Conversion

int a = 100;

double b = a;

Explicit Conversion

double x = 12.8;

int y = (int)x;

If Statement

if(condition)

{

    // statements

}

If-Else Statement

if(condition)

{

    // True Block

}

else

{

    // False Block

}

Switch Statement

switch(expression)

{

    case 1:

        break;

    default:

        break;

}

For Loop

for(int i = 1; i <= 5; i++)

{

    // statements

}

While Loop

while(condition)

{

    // statements

}

Do-While Loop

do

{

    // statements

}

while(condition);

Foreach Loop

foreach(int item in array)

{

    Console.WriteLine(item);

}

Break Statement

break;

Continue Statement

continue;

Return Statement

return value;

Namespace

namespace College

{

}

Using Directive

using System;

Frequently Confused Concepts

Concept 1Concept 2Difference
IdentifierKeywordIdentifier is user-defined; keyword is reserved.
VariableConstantVariable changes; constant remains fixed.
===Assignment vs comparison.
charstringSingle character vs sequence of characters.
Value TypeReference TypeStores value vs stores reference.
Implicit ConversionExplicit ConversionAutomatic vs manual conversion.
if-elseswitchCondition-based vs value-based selection.
forwhileKnown iterations vs unknown iterations.
whiledo-whileCondition checked before vs after execution.
forforeachCounter-controlled vs collection traversal.
breakcontinueExit loop vs skip current iteration.
NamespaceClassNamespace organizes types; class defines objects.

Memory Tricks

Loop Selection

Type Conversion

Selection Statements

Jump Statements

Namespace

Namespace = Folder

Class = File

using = Shortcut

Frequently Asked Practical Programs

The following programs are frequently asked in TU practical examinations:

  1. Program to find the largest of three numbers using if-else.
  2. Program to calculate grade using switch.
  3. Program to print multiplication tables using a for loop.
  4. Program to display even and odd numbers.
  5. Program to calculate factorial using a while loop.
  6. Program to generate the Fibonacci series.
  7. Program to reverse a number.
  8. Program to check whether a number is prime.
  9. Program to display elements of an array using foreach.
  10. Program demonstrating break and continue.
  11. Program illustrating command-line arguments.
  12. Program demonstrating namespaces.

Frequently Asked Viva Questions

Q1. What is the entry point of a C# program?

Answer: The Main() method.

Q2. What is the difference between = and ==?

Answer: = assigns a value, whereas == compares two values.

Q3. Why are comments used?

Answer: To improve readability and documentation. They are ignored by the compiler.

Q4. Which loop executes at least once?

Answer: do-while loop.

Q5. Which loop is best for arrays?

Answer: foreach loop.

Q6. What is a namespace?

Answer: A logical container that organizes related classes and avoids naming conflicts.

Q7. What is implicit type conversion?

Answer: Automatic conversion from a smaller compatible data type to a larger one without explicit casting.

Q8. What is the difference between value types and reference types?

Answer: Value types store actual data, whereas reference types store the memory address of objects.

Q9. What is the purpose of the using directive?

Answer: It imports a namespace so its members can be used without writing the fully qualified name.

Q10. Which statement exits a loop immediately?

Answer: break.

Complete Unit II Cheat Sheet

TopicRemember
Entry PointMain()
Comments//, /* */, ///
Constantconst
Namespace Importusing
Equality==
Assignment=
StringDouble quotes (” “)
CharSingle quotes (‘ ‘)
Array IndexStarts from 0
Fixed Loopfor
Unknown Loopwhile
Execute Oncedo-while
Array Traversalforeach
Exit Loopbreak
Skip Iterationcontinue
Exit Methodreturn

Common Programming Errors

❌ Using = instead of == inside conditions.

❌ Forgetting semicolons (;).

❌ Accessing an array index outside its valid range.

❌ Infinite loops due to incorrect loop conditions.

❌ Forgetting to increment or decrement loop variables.

❌ Declaring variables without initialization when required.

❌ Missing break statements in switch cases.

❌ Omitting the using directive for required namespaces.

⭐ One-Night Revision Box (Unit II)

UNIT III 

Short Questions (5 Marks)

Q1. What is a Class? Explain with a suitable example.

Q2. What is a Constructor? Explain its characteristics.

Q3. Differentiate between Constructors and Methods.

Q4. Explain the this Keyword in C#.

Q5. What are Properties in C#?

Q6. What is an Indexer? Explain with a suitable example.

Q7. Differentiate between Fields and Properties.

Q8. What are Static Constructors and Static Classes?

Q9. What is a Finalizer? Explain with a suitable example.

Q10. What is Dynamic Binding?

Q11. Explain Operator Overloading with a complete C# program.

Q12. Explain Inheritance with a suitable C# program.

Q13. Explain Abstract Classes and Abstract Methods.

Q14. Explain the base Keyword with an example.

Q15. Explain Method Overloading. Differentiate it from Method Overriding.

Long Questions (10 Marks) 

Q1. Explain Inheritance with a Suitable C# Program.

Q2. Explain Abstract Classes and Abstract Methods with Suitable Examples.

Q3. Differentiate between Interface and Abstract Class.

Q4. Explain Operator Overloading with a Complete C# Program.

Q5. Explain Method Overloading and Compare it with Method Overriding.

Q6. Explain Access Modifiers with Suitable Examples.

Q7. Explain Structures (Structs) and Compare them with Classes.

Q8. Explain Properties and Indexers with Suitable Examples.

Important Syntax

class Child : Parent

abstract class Shape

interface IPrint

struct Student

enum Day

{

    Sunday,

    Monday

}

class Box<T>

{

}

Frequently Asked Comparisons

Programming Questions to Practice

⭐ One-Night Revision Box ( Unit III )

UNIT IV 

Short Questions (5 Marks)

Q1. Explain Delegates in C#.

Q2. Differentiate between Delegates and Interfaces.

Q3. Explain Multicast Delegates.

Q4. Explain Events in C#.

Q5. Differentiate between Delegates and Events.

Q6. Explain Lambda Expressions with Examples.

Q7. Explain Exception Handling in C#.

Q8. Differentiate between throw, try-catch, finally, and throw.

Q9. Explain Language Integrated Query (LINQ).

Q10. Explain LINQ Query Syntax and Method Syntax.

Q11. Explain Advantages of LINQ.

Q12. Explain ADO.NET Architecture.

Q13. Explain Connection, Command, DataReader, DataAdapter, and DataSet.

Q14. Explain Connected and Disconnected Architecture in ADO.NET.

Q15. Explain CRUD Operations in ADO.NET.

Q16. Explain ASP.NET Page Life Cycle.

Long Questions (10 Marks)

Q1. Explain Delegates and Multicast Delegates with Complete C# Programs.

Q2. Explain Events in C# with a Suitable Example.

Q3. Explain Lambda Expressions with Complete C# Programs.

Q4. Explain Exception Handling in C# with Suitable Example.

Q5. Explain LINQ Architecture with Query Syntax and Method Syntax.

Important Definitions

Delegate

A delegate is a type-safe reference type in C# that stores the reference of one or more methods and allows methods to be passed as parameters.

Important points:

Multicast Delegate

A multicast delegate is a delegate that can store references to multiple methods and execute them sequentially.

Important points:

Event

An event is a notification mechanism in C# that allows an object to inform other objects when a particular action occurs.

Important points:

Lambda Expression

A lambda expression is an anonymous function that provides a shorter way to write methods using the lambda operator (=>).

Important points:

Exception Handling

Exception handling is a mechanism used to detect and handle runtime errors to prevent abnormal program termination.

Important points:

LINQ

LINQ (Language Integrated Query) is a C# feature that allows querying different data sources using a common query syntax.

Data sources:

ADO.NET

ADO.NET is a Microsoft technology used for connecting .NET applications with databases and performing data operations.

Main components:

ASP.NET

ASP.NET is a Microsoft web development framework used to create dynamic web applications and web services.

Features:

Important Syntax Revision

Delegate Declaration

delegate returnType DelegateName(parameters);

Example:

delegate void Display();

Delegate Assignment

DelegateName obj = MethodName;

Multicast Delegate

Adding methods:

delegateObject += MethodName;

Removing methods:

delegateObject -= MethodName;

Event Declaration

public event DelegateName EventName;

Lambda Expression

(parameters) => expression;

Example:

x => x * x;

Exception Handling

try

{

}

catch(Exception e)

{

}

finally

{

}

Throw Statement

throw new Exception(“Error Message”);

LINQ Query Syntax

var result =

from item in collection

where condition

select item;

LINQ Method Syntax

collection.Where(x => condition);

ADO.NET Connection

SqlConnection con =

new SqlConnection(connectionString);

SQL Command

SqlCommand cmd =

new SqlCommand(query, con);

Frequently Confused Concepts

ConceptDifference
Delegate vs EventDelegate stores method reference; event provides notification mechanism
Delegate vs InterfaceDelegate represents methods; interface defines class behavior
Normal Delegate vs Multicast DelegateNormal delegate calls one method; multicast calls multiple methods
Method vs Lambda ExpressionMethod has a name; lambda is anonymous
Exception vs ErrorException can be handled; errors are generally serious system failures
throw vs throwsC# uses throw; throws belongs to Java
try vs finallytry contains risky code; finally executes cleanup code
LINQ vs SQLLINQ is integrated into C#; SQL is database query language
DataReader vs DataSetDataReader is connected and fast; DataSet is disconnected and flexible
Connection vs CommandConnection opens database link; Command executes SQL operations

Memory Tricks

Delegate/Event Relationship

Remember:

D → E

Delegate → Event

Events are built on delegates.

Exception Handling Order

Remember:

T-C-F-T

Try

Catch

Finally

Throw

ADO.NET Components

Remember:

C C D D D

Connection

Command

DataReader

DataAdapter

DataSet

LINQ Data Sources

Remember:

O D X

Objects

Database

XML

Frequently Asked Practical Programs

The following programs are commonly asked in TU practical examinations.

1. Program to Demonstrate Delegate

using System;

class Program

{

    delegate void Message();

    static void Display()

    {

        Console.WriteLine(“Hello Delegate”);

    }

    static void Main()

    {

        Message msg = Display;

        msg();

    }

}

Output:

Hello Delegate

2. Program to Demonstrate Multicast Delegate

using System;

class Program

{

    delegate void Show();

    static void First()

    {

        Console.WriteLine(“First”);

    }

    static void Second()

    {

        Console.WriteLine(“Second”);

    }

    static void Main()

    {

        Show s = First;

        s += Second;

        s();

    }

}

Output:

First

Second

3. Program Using Lambda Expression

using System;

class Program

{

    delegate int Add(int a,int b);

    static void Main()

    {

        Add sum = (x,y)=>x+y;

        Console.WriteLine(sum(5,10));

    }

}

Output:

15

4. Program for Exception Handling

using System;

class Program

{

    static void Main()

    {

        try

        {

            int a = 10;

            int b = 0;

            Console.WriteLine(a/b);

        }

        catch(Exception e)

        {

            Console.WriteLine(“Error Occurred”);

        }

    }

}

Output:

Error Occurred

5. Program Using LINQ

using System;

using System.Linq;

class Program

{

    static void Main()

    {

        int[] numbers = {1,2,3,4,5};

        var result =

        numbers.Where(n=>n>3);

        foreach(int n in result)

        {

            Console.WriteLine(n);

        }

    }

}

Output:

4

5

6. Database Connectivity Steps Using ADO.NET

Create Connection

        |

        ▼

Open Connection

        |

        ▼

Create Command

        |

        ▼

Execute Query

        |

        ▼

Retrieve Data

        |

        ▼

Close Connection

Frequently Asked Viva Questions with Answers

Q1. What is a delegate?

Answer: A delegate is a type-safe reference to a method.

Q2. Why are delegates used?

Answer: Delegates are used for callbacks, events, and dynamic method invocation.

Q3. What is a multicast delegate?

Answer: A delegate that can execute multiple methods sequentially.

Q4. What is the purpose of an event?

Answer: Events are used to notify objects when an action occurs.

Q5. What is the lambda operator?

Answer: The => operator is called the lambda operator.

Q6. What are the keywords used in exception handling?

Answer: try, catch, finally, and throw.

Q7. What is LINQ?

Answer: LINQ is a feature of C# used to query different data sources.

Q8. What is ADO.NET used for?

Answer: ADO.NET is used for database connectivity in .NET applications.

Q9. Difference between DataReader and DataSet?

Answer:

DataReader:

DataSet:

Q10. What is ASP.NET?

Answer: ASP.NET is a framework for developing dynamic web applications.

Complete Unit IV Cheat Sheet

TopicRemember
DelegateMethod reference
Multicast DelegateMultiple method execution
EventNotification mechanism
LambdaAnonymous function
ExceptionRuntime error handling
tryRisky code
catchHandle error
finallyCleanup
throwGenerate exception
LINQQuery in C#
Query SyntaxSQL-like syntax
Method SyntaxLambda-based syntax
ADO.NETDatabase connectivity
ConnectionOpens database link
CommandExecutes SQL
DataReaderFast connected reading
DataSetDisconnected storage
ASP.NETWeb application framework

Common Programming Errors

❌ Forgetting to assign a method to a delegate.

✔ Correct:

delegateObject = MethodName;

❌ Calling an event from outside its declaring class.

✔ Correct:

Only the declaring class should raise the event.

❌ Not handling possible exceptions.

✔ Correct:

Use:

try-catch

❌ Writing incorrect LINQ syntax.

✔ Correct:

from x in collection

select x;

❌ Forgetting to open database connection.

✔ Correct:

connection.Open();

❌ Not closing database connections.

✔ Correct:

connection.Close();

⭐ One-Night Revision Box (Unit IV)

Exit mobile version