C# Two Mark
Transcript of C# Two Mark
8/12/2019 C# Two Mark
http://slidepdf.com/reader/full/c-two-mark 1/7
1. What is .net?
Microsoft .NET (pronounced “dot net”) is a software component that runs on the Windows operating
system. .NET provides tools and libraries that enable developers to create Windows software much faster and
easier. .NET benefits end-users by providing applications of higher capability, quality and security. The .NET
Framework must be installed on a user’s PC to run .NET applications.
2. What are the Para passing tech available in C#?
In C#, parameters can be passed either by value or by reference. Passing parameters by reference allows
function members (methods, properties, indexers, operators, and constructors) to change the value of the
parameters and have that change persist. To pass a parameter by reference, use the ref or out keyword.
3. How do you create a dynamic array?
A dynamic array does not have a predefined size. The size of a dynamic array increases as you add new
items to the array.
e.g., int[] intArray;
4. What are the Purpose of Creating namespace in .NET?
Namespaces are not a replacement for assemblies, but a second organizational method that complements
assemblies. Namespaces are a way of grouping type names and reducing the chance of name collisions. A
namespace can contain both other namespaces and types. The full name of a type includes the combination of
namespaces that contain that type.
5. What are delegates? Give Example.6
A delegate is a type-safe object that can point to another method (or possibly multiple methods) in the
application, which can be invoked at later time.
namespaceMyFirstDelegate
{
public delegate intMyDelegate(int x, int y);
public class MyClass
{
public static int Add(int x, int y)
{
return x + y;
}
public static int Multiply(int x, int y)
{
return x * y;
}}
class Program
{
static void Main(string[] args)
{
MyDelegate del1 = new MyDelegate(MyClass.Add);
intaddResult = del1(5, 5);
Console.WriteLine("5 + 5 = {0}\n", addResult);
MyDelegate del2 = new MyDelegate(MyClass.Multiply);
intmultiplyResult = del2(5, 5);
Console.WriteLine("5 X 5 = {0}", multiplyResult);
Console.ReadLine();
}}
}
8/12/2019 C# Two Mark
http://slidepdf.com/reader/full/c-two-mark 2/7
6. What are Sealed Classes?
Sealed classes are used to restrict the inheritance feature of object oriented programming. Once a class is
defined as sealed class, this class cannot be inherited.
In C#, the sealed modifier is used to define a class as sealed. In Visual Basic .NET, NotInheritable
keyword serves the purpose of sealed. If a class is derived from a sealed class, compiler throws an error.
7. What is an Interface?
An interface looks like a class, but has no implementation. The only thing it contains are declarations of events,
indexers, methods and/or properties. The reason interfaces only provide declarations is because they are
inherited by classes and structs, which must provide an implementation for each interface member declared.
interfaceIMyInterface
{
voidMethodToImplement();
}
8. What do you mean by web services?
The term Web services describes a standardized way of integrating Web-based applications using the XML,
SOAP, WSDL and UDDI open standards over an Internet protocol backbone. XML is used to tag the data,
SOAP is used to transfer the data, WSDL is used for describing the services available and UDDI is used for
listing what services are available.
9. What are threads? How are they useful?
A thread refers to a different parallel line of execution. In C# exist a class that let you create this execution
line. The Thread class.
This execution capability is generally used to implement interactive interfaces meanwhile a large process
is performed in background.10. What is versioning?
The C# language is designed such that versioning between base and derived classes in different libraries can
evolve and maintain backwards compatibility. This means, for example, that the introduction of a new member
in a base class with the same name as a member in a derived class is not an error.
11. What are boxing & unboxing?
Boxing is the process of converting a value type to the type object or to any interface type implemented by this
value type. When the CLR boxes a value type, it wraps the value inside a System.Object and stores it on the
managed heap. Unboxing extracts the value type from the object. Boxing is implicit; unboxing is explicit. The
concept of boxing and unboxing underlies the C# unified view of the type system, in which a value of any type
can be treated as an object.
12. Define inter-operability. How does .NET achieve this?
Interoperability is the ability of diverse systems and organizations to work together (inter-operate). The
term is often used in a technical systems engineering sense, or alternatively in a broad sense, taking into
account social, political, and organizational factors that impact system to system performance.
.NET runtime allows us to use legacy COM code from .NET components. We can call it backward
compatibility. In the same way, .NET runtime also provides us forward compatibility, means accessing .NET
components from COM components.
8/12/2019 C# Two Mark
http://slidepdf.com/reader/full/c-two-mark 3/7
13. Define Polymorphism?
Through inheritance, a class can be used as more than one type; it can be used as its own type, any base
types, or any interface type if it implements interfaces. This is called polymorphism. In C#, every type is
polymorphic. Types can be used as their own type or as aObject instance, because any type automatically treats
Object as a base type.
14. Define Marshaling?
Marshaling is the process of creating a bridge between managed code and unmanaged code; it is the homer
that carries messages from the managed to the unmanaged environment and reverse. It is one of the core
services offered by the CLR (Common Language Runtime.)
15. Is it possible to have two main() in a C#?
Yes possible. Go to solution explorer ->right click on projectname-> properties.
16. What is the use of static construction in C#?
C# supports two types of constructor, a class constructor (static constructor) and an instance constructor
(non-static constructor).
Static constructor is a class constructor, they are guaranteed to be called as soon as we refer to that class or
by creating an instance of that class.
17. What is the use of new in inheritance?
Hides the original function (which doesn't have to be virtual), providing different functionality. This
should only be used where it is absolutely necessary.
18. List out the server side state mgt options supposed by ASP.NET?
Application state, session state, and databases.
19. List out the different types of applications that can be created on .NET?
o Customer relationship managemento Accounting applications
o Product/inventory applications
o Warehousing applications using hand-held devices
o Web sites
o Value chain/supply management
o Integration with partners through the Internet
o XML Web services
o PDA (hand-held) applications
20. What are assemblies?
Assemblies form the fundamental unit of deployment, version control, reuse, activation scoping, and
security permissions for a .NET-based application. Assemblies take the form of an executable (.exe) file or
dynamic link library (.dll) file, and are the building blocks of the .NET Framework. They provide the common
language runtime with the information it needs to be aware of type implementations.
21. Write any 4 difference between C# & C+?
C# uses a garbage collector as part of the language spec. Many garbage collectors are available for C++,
but this is not built into the language.
C++ has multiple inheritance (of implementation), C# does not (although it does have multiple inheritance
of interface).
C# has delegates, which are a powerful alternative to C++'s function pointers and pointers-to-members.
C# has syntax for properties and events.
8/12/2019 C# Two Mark
http://slidepdf.com/reader/full/c-two-mark 4/7
22. What are the different tokens supported by C#?
Identifier, keyword, integer-literal, real-literal, character-literal, string-literal, & operator-or-punctuator.
23. What are verbation strings?
C# supports two forms of string literals: regular string literals and verbatim string literals.
A verbatim string literal consists of an@ character followed by a double-quote character, zero or more
characters, and a closing double-quote character. A simple example is @"hello".
24. What do you mean by Overriding?
An override method provides a new implementation of a member inherited from a base class. The method
overridden by an override declaration is known as the overridden base method. The overridden base method
must have the same signature as the override method.
You cannot override a non-virtual or static method. The overridden base method must be virtual, abstract,
or override.
25. What is an Event?
An event in C# is a way for a class to provide notifications to clients of that class when some interesting
thing happens to an object. The most familiar use for events is in graphical user interfaces; typically, the
classes that represent controls in the interface have events that are notified when the user does something to the
control (for example, click a button).
26. Write the different numeric formats supported by C#?
C or
c
Currency Console.Write("{0:C}", 2.5);
Console.Write("{0:C}", -2.5);
D or d Decimal Console.Write("{0:D5}", 25);
E or e Scientific Console.Write("{0:E}", 250000);
F or f Fixed-point Console.Write("{0:F2}", 25);
Console.Write("{0:F0}", 25);
G or g General Console.Write("{0:G}", 2.5);
N or n Number Console.Write("{0:N}", 2500000);
X or x Hexadecimal Console.Write("{0:X}", 250);
Console.Write("{0:X}", 0xffff);
27. What are the components of .NET framework?
It mainly contains two components,
1. Common Language Runtime (CLR)
2. .Net Framework Class Library
28. What is an IC code?
29. What is masking?
Masking is the process of changing bits in a byte.
8/12/2019 C# Two Mark
http://slidepdf.com/reader/full/c-two-mark 5/7
01010011 - Value
1DD10DD1 - Data
01100110 - Mask (From Data)
0DD00DD0 - (Mask & Data)
30. What is namespace?
The namespace keyword is used to declare a scope. This namespace scope lets you organize code and gives
you a way to create globally unique types.
Namespaces implicitly have public access and this is not modifiable. For a discussion of the access modifiers
you can assign to elements within a namespace
31. What is an inner class?
A type defined within a class or struct is called a nested type. For example:
class Container
{
class Nested
{
Nested() { }
}
}
32. List the valid operators of C# that can be overloaded in C#?
unary operators, binary operators, & comparison operators are overloaded.
33. What is the basic I/O method supported by C#?
Streams are objects to work with input/output. A stream is an abstraction of a sequence of bytes, such as a
file, an input/output device, an inter-process communication pipe, or a TCP/IP socket. In C#, we have a
Streamclass, that is an abstract class for all streams. There are additional classes that derive from the Stream
class and make the programming a lot easier.
MemoryStream
A MemoryStream is a stream which works with data in a computer memory.
StreamReader&StreamWriter
StreamReader reads characters from a byte stream. It defaults to UTF-8 encoding. StreamWriter writes
characters to a stream in a particular encoding.
FileStream
A FileStream class uses a stream on a file on the filesystem. This class can be used to read from files, write
to files, open them and close them.
XmlTextReader
We can use streams to read xml data. The XmlTextReader is the class to read xml files in C#. The class is
forward-only and read-only.
Files and directories
The .NET framework provides other classes that we can use to work with files and directories.A File class is a higher level class that has static methods for file creation, deletion, copying, moving and
opening. These methods make the job easier.
8/12/2019 C# Two Mark
http://slidepdf.com/reader/full/c-two-mark 6/7
8/12/2019 C# Two Mark
http://slidepdf.com/reader/full/c-two-mark 7/7
37. What is exception?
The term exception is shorthand for the phrase "exceptional event."
Definition: An exception is an event, which occurs during the execution of a program, that disrupts the normal
flow of the program's instructions.