C# 2MARK
C# 2MARK
1. Define C#?
C# is a modern, object-oriented programming language developed by
Microsoft as part of the .NET framework. It is used to build a wide variety of
applications, including web, desktop, and mobile applications.
UNIT 3
Here are the answers with appropriate detail:
1. What is C#?
C# is a modern, object-oriented programming language developed by
Microsoft. It is designed for building a variety of applications that run on
the .NET framework and offers features for software robustness, durability, and
productivity.
2. Name the 4 Pillars of OOP in C#.
The four pillars of Object-Oriented Programming (OOP) in C# are:
1. Encapsulation
2. Inheritance
3. Polymorphism
4. Abstraction
3. Define Encapsulation and Polymorphism.
Encapsulation: Encapsulation is the bundling of data (fields) and
methods that operate on the data into a single unit or class. It restricts
access to the internal state and allows it to be modified only through
methods.
Polymorphism: Polymorphism allows methods to have the same name
but behave differently based on the object that invokes them. It can be
achieved through method overriding and method overloading.
4. What are C# Class Properties? And its General Form?
Class properties in C# are special methods called accessors, which are used to
read, write, or compute the values of private fields. The general form includes
get and set accessors:
public class ClassName
{
private int field;
public int PropertyName
{
get { return field; }
set { field = value; }
}
}
5. What is Inheritance? Mention its Types.
Inheritance is a mechanism where one class (child class) derives properties and
behaviors from another class (parent class). Types of inheritance include:
Single Inheritance
Multilevel Inheritance
Hierarchical Inheritance
Multiple Inheritance (through interfaces)
6. Define Super Class and Base Class.
Super Class: A general term for a class from which other classes inherit
properties and methods.
Base Class: A specific term in C# used to describe the parent class in
inheritance.
7. Define Inheritance and Mention its Syntax.
Inheritance is a way to create a new class that is based on an existing class. It is
defined using the : symbol in C#:
class DerivedClass : BaseClass
{
// additional members of DerivedClass
}
UNIT 4
Here are the concise answers:
1. Define Types of Error.
Errors in programming are generally classified into:
Syntax Errors: Mistakes in code syntax.
Runtime Errors: Errors occurring during program execution.
Logical Errors: Flaws in the program's logic leading to incorrect results.
2. List Some of the Purpose of Exception Handling.
Gracefully handle errors.
Maintain program flow without crashing.
Provide meaningful error messages to users.
Log errors for debugging purposes.
3. Give the Syntax of Exception Handling.
try
{
// Code that may throw an exception
}
catch (ExceptionType e)
{
// Handle the exception
}
finally
{
// Code that executes after try or catch
}
UNIT 5
Here are the answers with concise explanations:
1. Define List.
A List in C# is a collection that can dynamically grow or shrink in size, allowing
storage of elements that can be accessed by index.
2. What are the Types of Collections?
ArrayList
List
Dictionary
HashSet
Queue
Stack
3. Write a Syntax to Create ArrayList.
ArrayList arrayList = new ArrayList();
4. Define Hash Table.
A HashTable is a collection that stores key-value pairs, where each key is
unique and used to access its corresponding value.
5. Define IDE.
An Integrated Development Environment (IDE) is a software application that
provides comprehensive facilities for software development, such as code
editor, debugger, and build automation tools.
6. Write Different IDE Modes.
Design Mode: Used for designing the UI.
Run Mode: Executes the application.
Debug Mode: Allows debugging of the code.
7. Define Toolbar.
A Toolbar is a graphical control element that contains buttons, icons, or menus
for quick access to commonly used functions in an application.
8. What are Generic Classes?
Generic Classes in C# are classes defined with a type parameter, allowing the
same class to be used with different data types:
class GenericClass<T>
{
public T Data { get; set; }
}
9. Define Form.
A Form is a window or screen in a graphical user interface that acts as a
container for controls like buttons, textboxes, and labels.
10. What is Event?
An Event is an action or occurrence detected by a program, often from user
input, such as a mouse click or key press.
11. What is TextBox?
A TextBox is a control that allows users to input text in a form.
12. Write Any Two Properties of TextBox Control.
Text: Gets or sets the text in the TextBox.
MaxLength: Sets the maximum number of characters allowed.
13. Write Types of Items in Menu Strip.
Menu Items
Submenu Items
Separator
14. Write Types of Items in Context Menu Strip.
Context Menu Items
Submenu Items
Separator