Dot Net -- Questions and Answers:[Difference
Between]
Part-I
1. What is the difference between public, static and
void?
Public: The
keyword public is an access modifier that tells the C# compiler that the Main
method is accessible by anyone.
Static: The
keyword static declares that the Main method is a global one and can be called
without creating an instance of the class. The compiler stores the address of
the method as the entry point and uses this information to begin execution
before any objects are created.
Void: The keyword void is a type modifier that states that
the Main method does not return any value.
2. What are value types and reference types?
Value types are stored in the
Stack.
Examples: bool, byte, chat, decimal, double, Enum, float,
int, long, sbyte, short, strut, uint, ulong, ushort.
Reference types are stored in the Heap.
Examples: class, delegate, interface, object, string.
3. What is the difference between private and public
keyword?
Private: The private keyword is the default
access level and most restrictive among all other access levels. It gives least
permission to a type or type member. A private member is accessible only within
the body of the class in which it is declared.
Public: The public keyword is most liberal
among all access levels, with no restrictions to access what so ever. A public
member is accessible not only from within, but also from outside, and gives
free access to any member declared within the body or outside the body.
4. How is method overriding different from method
overloading?
When overriding a method, you
change the behavior of the method for the derived class. Overloading a method
simply involves having another method with the same name within the class.
5. What is the difference between ref & out
parameters?
An argument passed to a ref
parameter must first be initialized. Compare this to an out parameter, whose
argument does not have to be explicitly initialized before being passed to an
out parameter.
6. What is Authentication and Authorization?
Authentication is the process of
identifying users. Authentication is identifying/validating the user against
the credentials (username and password).
Authorization performs after authentication. Authorization
is the process of granting access to those users based on identity.
Authorization allowing access of specific resource to user.
7. What is difference between constants, read only and,
static?
Constants: The
value can’t be changed.
Read-only: The
value will be initialized only once from the constructor of the class.
Static: Value can
be initialized once.
8. What is the difference between string keyword and
System? String class?
String keyword is an alias for
System. String class. Therefore, System. String and string keyword are the
same, and you can use whichever naming convention you prefer. The String class
provides many methods for safely creating, manipulating, and comparing strings.
9. What is the difference between Custom Control and User
Control?
Custom Controls are compiled code
(Dlls), easier to use, difficult to create, and can be placed in toolbox. Drag
and Drop controls. Attributes can be set visually at design time. Can be used
by Multiple Applications (If Shared Dlls), Even if Private can copy to bin
directory of web application add reference and use. Normally designed to
provide common functionality independent of consuming Application.
User Controls are similar to those of ASP include files,
easy to create, cannot be placed in the toolbox and dragged - dropped from it.
A User Control is shared among the single application files.
10. What is the difference between break and continue
statement?
The break statement is used to
terminate the current enclosing loop or conditional statements in which it
appears. We have already used the break statement to come out of switch
statements.
The continue statement is used to alter the sequence of
execution. Instead of coming out of the loop like the break statement did, they
continue statement stops the current iteration and simply returns control back
to the top of the loop.
11. What is the difference between static and instance
methods?
A method declared with a static
modifier is a static method. A static method does not operate on a specific
instance and can only access static members.
A method declared without a static modifier is an instance
method. An instance method operates on a specific instance and can access both
static and instance members. The instance on which an instance method was
invoked can be explicitly accessed as this. It is an error to refer to this in
a static method.
12. What is the difference between Array and Arraylist?
An array is a collection of the
same type. The size of the array is fixed in its declaration. A linked list is
similar to an array but it doesn’t have a limited size.
13. What is the difference between console and window
application?
A console
application, which is designed to run at the command line with no user
interface.
A Windows
application, which is designed to run on a user’s desktop and has a user
interface.
14. What is the difference between Array and Linked List?
Array is a simple sequence of
numbers which are not concerned about each others positions. They are
independent of each others positions. Adding, removing or modifying any array
element is very easy. Compared to arrays, linked list is a complicated sequence
of numbers.
15. What is the difference between CONST and READONLY?
Both are meant for constant
values. A const field can only be initialized at the declaration of the field.
A read only field can be initialized either at the declaration or.
16. What is the main difference between a sub procedure
and a function?
Sub procedures do not return a
value, while functions do.
17. How does C# differ from C++?
v
C# does not support #include statement. It uses
only using statement.
v
In C# , class definition does not use a
semicolon at the end.
v
C# does not support multiple code inheritance.
v
Casting in C# is much safer than in c++.
v
In C# switch can also be used on string values.
v
Command line parameters array behave differently
in C# as compared to C++.
18. What is the difference between Shadowing and
Overriding?
Overriding redefines
only the implementation while shadowing redefines the whole element.
In overriding
derived classes can refer the parent class element by using "ME"
keyword, but in shadowing you can access it by "MYBASE".
19. What is a basic difference between the while loop and
do while loop in C#?
The while loop tests its condition
at the beginning, which means that the enclosed set of
Statements run for zero or more number of times if the
condition evaluates to true. The do while loop iterates a set of statements at
least once and then checks the condition at the end.
20. What is the main difference between a subprocedure
and a function?
Subprocedures do not return a
value, while functions do.
21. What is the difference between an abstract method
& virtual method?
An Abstract method does not
provide an implementation and forces overriding to the deriving class (unless
the deriving class also an abstract class), where as the virtual method has an
implementation and leaves an option to override it in the deriving class. Thus
Virtual method has an implementation & provides the derived class with the
option of overriding it. Abstract method does not provide an implementation
& forces the derived class to override the method.
.
22. What are the differences between
System. String and System.Text.StringBuilder classes?
System. String is immutable. When we
modify the value of a string variable then a new memory is allocated to the new
value and the previous memory allocation released. System.StringBuilder was
designed to have concept of a mutable string where a variety of operations can
be performed without allocation separate memory location for the modified
string.
23. What’s the difference between the
System.Array.CopyTo () and System.Array.Clone ()?
Using Clone () method, we creates a new
array object containing all the elements in the original array and using CopyTo
() method, all the elements of existing array copies into another existing
array. Both the methods perform a shallow copy.
24. What is the
difference between Finalize () and Dispose () methods?
Dispose () is called when we want for
an object to release any unmanaged resources with them. On the other hand
Finalize () is used for the same purpose but it doesn’t assure the garbage
collection of an object.
25. What is difference
between is and as operators in c#?
“is” operator is used to check the
compatibility of an object with a given type and it returns the result as
Boolean.
“as” operator is used for casting of
object to a type or a class.
26. What is difference
between the “throw” and “throw ex” in .NET?
“Throw” statement preserves original
error stacks whereas “throw ex” has the stack trace from their throw point. It
is always advised to use “throw” because it provides more accurate error
information.
27. What is the difference
between direct cast and ctype?
Direct Cast is used to convert the type
of an object that requires the run-time type to be the same as the specified
type in Direct Cast.
Ctype is used for conversion where the
conversion is defined between the expression and the type.
28. What’s the difference between and
XML documentation tag?
Single line code
example and multiple-line code example.
29. What’s the difference between the
Debug class and Trace class?
Documentation looks
the same. Use Debug class for debug builds, use Trace class for both debug and
release builds.
30.
What is the difference between VB and VB.Net?
Following are the differences
between VB and VB.Net:
VB
|
VB.Net
|
Platform dependent
|
Platform Independent
|
VB is backward compatible
|
VB.Net is not backward compatible
|
Interpreted
|
Compiler Language
|
Exception Handling by ‘On
Error…..Goto’
|
Exception Handling by ‘Try….Catch’
|
Cannot develop multi-threaded
applications
|
Can develop multi thread applications
|
31.
What is the difference between C# and VB.Net?
Following table gives differences
between C# and VB.Net:
VB.Net
|
C#
|
Optional Parameters are accepted
|
Optional Parameters are not
accepted
|
Not case sensitive
|
Case Sensitive
|
Nothing is used to release
unmanaged resources
|
‘Using’ is used to release
unmanaged resources
|
Support of Both structured and
unstructured error handling
|
Unstructured error handling
|
Thanks to GOOGLE.
No comments:
Post a Comment