You are on page 1of 3

1) What are the differences between TypeOf() and GetType()?

S.N TypeOf() GetType()


o
1 Its an operator Its a method
2 Can't be overloaded Has lot of overloads

2) What are the differences between const and readonly?

S.N const readonly


o
1 It cannot be static It can be instance level or static
2 It is evaluated at design time It is evaluated at run time
3 It is initialized at declaration It is initialized at declaration and in
constructor
4 It must be of integral type or In addition, it can have complex
enumeration types with new keyword and
enumerations are not allowed

3) What are the Differences between Abstract Class and Interface?

S.N Abstract Class Interface


o
1 It can have implemented It cannot have implemented
Methods Methods
2 A class can inherit only one A Class can implement any number
abstract class of Interfaces
3 We go for Abstract classes on We go for Interface on such
such situations where we need situations where we need to give
to give common functionality for common functionality for group of
group of related classes un-related classes
4 If we add a new method, then If we add a new method, then we
we can provide a default need to change all the existing work
implementation and so no need
to make any change to existing
work
5 Static and Instance constants Only Static constants are possible
are possible

4) What are the differences between Structure and Class?

S.N Structure Class


o
1 It is value type It is reference type
2 It is stored on stack It is stored on heap
3 It does not support inheritance It supports inheritance
4 It is suitable for small data It is suitable for complex data
structure structures
5) What are the differences between property and indexer?

S.N Property Indexer


o
1 A property can be static An indexer is always an instant
member member
2 The get accessor of a property The get accessor of an indexer
corresponds to a method with corresponds to the same formal
no parameters parameter lists as the indexer

6) What are the differences between overloading and overriding?

S.N Overloading Overriding


o
1 Same name in same / derived We need to provide different
class but with different / type of implementation than base class
parameter
2 Has different signature Has same signature
3 Otherwise called Compile-time Otherwise called Run-time
Polymorphism Polymorphism
7) What is the difference between Write() and WriteLine() methods?

S.N Write() WriteLine()


o
1 Write() method outputs one or WriteLine() method outputs one or
more values to the screen more values to the screen with a
without a newline character newline character

8) What is the difference between Read() and ReadLine() methods?

S.N Read() ReadLine()


o
1 Read() method returns a single ReadLine() method returns a string
character as int containing a line of text

9) What is the difference between ref and out parameters?

S.N Ref parameter Out parameter


o
1 An argument passed to a ref An argument passed to an output
parameter must be first parameter does not need to be
initialized explicitly initialized
10) What are the differences between Value Types and Reference
Types?

S.N Value Types Reference Types


o
1 It is stored on stack It is stored on heap
2 It can be accessed directly It can be accessed through
references
3 Life time of value type is Lifetime of reference type is
determined by lifetime of managed by .net framework
variable that contain them
4 Examples: All numeric data Examples: All arrays, String, Class
type, Boolean, char, Date, types, Delegate
Structure, enumerations

Note: Object is not any kind of type. You can create object of structure as
well as Class

Are not type: Namespaces, Modules, Events, properties, procedures,


variables, constants, & fields.

You might also like