Data Types of C#.Net Interview Questions(26) 
  
 
 
 
 
1.How
Data types can be Categorized in C#.Net?
A)
Data types can be Categorized into two types they are
              Ø  Value Types
              Ø  Reference Types
2.What
are the  broad classifications of data
types available in C#?
A)Data
types can be broadly divided into 2 types.They are:
1. Built in data
types.
2. User defined
data types.
3.List
Some of the Built in datatypes in C#?
A)Smoe of
exteremed built in datatypes in c# are:
            Ø  Int
           Ø  Float
           Ø  String
4.List the Different types in c#.Net?
A) 
DataType 
 | 
  
Common
  Language Runtime Structure 
 | 
  
StorageAllocation 
 | 
  
Value
  Range 
 | 
 ||
Boolean 
 | 
  
System.Boolean 
 | 
  
2 bytes 
 | 
  
True or False. 
 | 
 ||
Byte 
 | 
  
System.Byte 
 | 
  
1 byte 
 | 
  
0
  through 255 (unsigned). 
 | 
 ||
Char 
 | 
  
System.Char 
 | 
  
2 bytes 
 | 
  
  | 
 ||
Date 
 | 
  
System.DateTime 
 | 
  
8 bytes 
 | 
  
  | 
 ||
Decimal 
 | 
  
System.Decimal 
 | 
  
16 bytes 
 | 
  
  | 
 ||
Double 
(double-precision
  floating-point) 
 | 
  
System.Double 
 | 
  
8 bytes 
 | 
  
-1.79769313486231570E+308
  through 
-4.94065645841246544E-324
  for negative values; 4.94065645841246544E-324 through
  1.79769313486231570E+308 for positive values. 
 | 
 ||
Integer 
 | 
  
System.Int32 
 | 
  
4 bytes 
 | 
  
  | 
 ||
Long 
(long
  integer) 
 | 
  
System.Int64 
 | 
  
8 bytes 
 | 
  
-9,223,372,036,854,775,808
  through 9,223,372,036,854,775,807. 
 | 
 ||
Object 
 | 
  
System.Object (class) 
 | 
  
4 bytes 
 | 
  
Any type
  can be stored in a variable of type Object. 
 | 
 ||
Short 
 | 
  
System.Int16 
 | 
  
2 bytes 
 | 
  
  | 
 ||
  | 
  
System.Single 
 | 
  
4 bytes 
 | 
  
  | 
 ||
String 
(variable-length) 
 | 
  
System.String (class) 
 | 
  
Depends
  on implementing platform 
 | 
  
  | 
 
User-Defined Type 
(structure) 
 | 
  
  | 
  
Depends on implementing platform 
 | 
  
  | 
 
In this Data Types can
be categroized in C#.Net.
For More Info Visit:
5.What are the default
values for bool,int,double,string,char,reference-type variables? 
A)When the types are
declared then they have default values during declaration.It can be listed in
below  tabular format.
Type 
 | 
  
Default Value 
 | 
 
bool 
 | 
  
False 
 | 
 
int  
 | 
  
0 
 | 
 
double 
 | 
  
0 
 | 
 
string 
 | 
  
“” 
 | 
 
char 
 | 
  
‘’ 
 | 
 
Reference type 
 | 
  
Null 
 | 
 
6.If you declare a
variable without any value assignment 
either of bool,int,double,string,char?
A)It gives an error
because bool,int,double,string,char types are value types.All value types
requires values. 
7. How to declare a constant variable in C#? What is
the use of the const keyword?
A)If a variable needs to
have a fixed value, that may not be changed across the application's 
life, then it may be
declared with the const keyword. The
value assigned to a constant variable (using the const keyword) must be known
at the time of compilation.
8.Can we assign a “null”
to value types?
A)Yes if we make value
types as a nullable types.
    E.G:int ?a=null 
//Is valid(It is nullable type declaration)
           int
a=null //Is not valid  
9.What is Nullable types?
A) Nullable types are instances of the Nullable
struct. A nullable type can represent the correct range of values for its
underlying value type, plus an additional null value. For example, a Nullable,
pronounced "Nullable of Int32," can be assigned any value from
-2147483648 to 2147483647, or it can be assigned the null value. A Nullable can
be assigned the values true false, or null.
10.What is Const?
A)Const values won’t be
changed.It can be declared as compile time.use “const” keyword to declare a
variable as constant.
   E.G: const int a=2;
11.What is Readonly? 
A)These values will be
evaluated at runtime.Even we can declare at compile time and it changes  according to runtime declaration.Use
“Readonly” keyword to declares a variable as readonly.
E.G:readonly int b;
12.What is the
difference between const and read only?
A)
Const 
 | 
  
Read-only 
 | 
 
Const can only be
  initialized at the time of declaration of the field. 
 | 
  
The value will be
  initialized either declaration time or the constructor of the class allowing
  you to pass the value at run time. 
 | 
 
Const values will evaluate
  at compile time only. 
 | 
  
Read only values will
  evaluate at runtime only. 
 | 
 
Const value can’t be
  changed these will be same at all the time. 
 | 
  
Read-only value can be
  changed at runtime. 
 | 
 
13.How do you create user defined data types in C#?
A)You use the struct,
class, interface, and enum constructs to create your own custom types. The .NET
Framework class library itself is a collection of custom types provided by
Microsoft that you can use in your own applications.
14.What is keywords in
C#.Net?
A)Keywords are
predefined reserved identifiers that have special meaning to the
compiler.Keywords cannot be used as variables in your program unless they
include @ as a prefix.
15.How many types of
keywords are there in C#.Net.List them?
A)C#.Net Supports 2
types of keywords.They are:
                 Ø  Reserved Keywords
                 Ø  Contextual Keywords
   There are 77 Reserved keywords and 6
contextual keywords present in C#.Net.
16.What is the case used
for keywords in C#.Net?
A)Lower case is used to
represent the keywords in C#.Net.
17.List some of Reserved
Keywords in C#.Net?
A)abstract,event,new,struct,as,explicit,null,switch,base,extern
etc……………..
18.List Contextual
Keywords?
A)There are 6 contextual
keywords are there.They are:
               1.      Get
               2.      Partial
               3.      Set
               4.      Value
               5.      Where
               6.      Yield
Contextual keyword is
used to provide a specific maning in the code,but it is not a reserved word in
C#.Net
19.Define “Get”?
A)”Get” defines an
acessor method or a property or an indexer.
20.Define “Set”?
A) ”Set” defines an
acessor method or a property or an indexer.
21.Define Partial ?
A)It defines an
classes,structs and interfaces throughout the same compilation unit
22.Define Where?
A)It adds constraints
i.e conditions to a generic declaration.
23.Define Yield?
A)It is used an iterator
block to return a value to the enumerator object or to signal the end of
iteration.
24.Define value?
A)Used to set accessors
and to add or remove event handlers.
25.What is a line
terminator in C#.Net?
A)Semicolon(;) is a line
terminator in C#.Net.
26.What are the Program
Control Structures in C#.Net?
A)In C#.Net Program
Control Structures can be classified into following types.They are:
              Ø  Conditional Statements(Simple If,If Else,Nested
If)
              Ø  Iteration or Looping type of
statements(For,Ehile,Do While,Foreach)
              Ø  Other types(Break,continue,jump,etc..)








0 comments:
Post a Comment