Dot Net
Dot Net
Dot Net
Answer: d
Explanation: By definition.
6. Which is the String method used to compare two strings with each other?
a) Compare To()
b) Compare()
c) Copy()
d) ConCat()
View Answer
Answer: a
Explanation: CompareTo() used to compare two strings by taking the length of
strings in considerations.
Answer: d
Explanation: Insert method() of string class used to join two strings s1 and s2.
Output :
DelhiJaipur
Answer: c
Explanation: Substring() of string class used to extract substrings from given
string. In the given substring condition, it extracts a substring beginning at 5th
position and ending at 4th position.
Answer: d
Explanation: By definition.
Ans d
Answer: c
Explanation: ‘Variables’ are essential locations in memory of computer that are
reserved for storing data used by an application. Each variable is given a name by
programmer and hence assigned a value. The name assigned to variable then used in
C# code to access value assigned to variable.
Q
static void Main(string[] args)
{
int a = 5;
int b = 10;
int c;
Console.WriteLine(c = a-- - ++b);
Console.WriteLine(b);
Console.ReadLine();
}
a) -7, 10
b) -5, 11
c) -6, 11
d) 15, 11
View Answer
Answer: c
4. What will be the output of the following C# code?
class Program
{
static void Main(string[] args)
{
int i ;
for ( i = 0; i < 5; i++)
{
int j = 0;
j += i;
Console. WriteLine(j);
}
Console. WriteLine(i);
Console. ReadLine();
}
}
a) 0, 1, 2, 3, 4, 5, 6
b) 0, 1, 2, 3, 4, 5
c) 0, 1, 2, 3, 4
d) 0, 1, 2, 3
View Answer
Answer: b
Explanation: None.
Output:
Answer: c
Explanation: By Definition.
Answer: b
Explanation: ‘int’ is 32 bit signed integer whereas ‘uint’ is 32 bit unsigned
integer. Range of int is larger than uint. So, the compiler cannot implicitly
convert from larger data type to smaller data type.
8.
static void Main(string[] args)
{
int a = 76;
char b;
b = (char)a;
Console.WriteLine(b);
Console.ReadLine();
}
a) Compiler will generate runtime error
b) Conversion is explicit type
c) Compiler will urge for conversion from ‘integer’ to ‘character’ data type
d) None of the mentioned
View Answer
Answer: b
Explanation: Since, given conversion is of explicit type as one data type is in
integer and other is in ‘char’. Compiler is needed to make a clear distinction
between both type of data types and hence, explicitly one need to specify data type
as compiler is unable to make automatic conversion.
Output : L
Arithmetic Operators
Answer: b
4. Correct order of priorities are:
a) ‘/’ > ‘%’ > ‘*’ > ‘+’
b) ‘/’ > ‘*’ > ‘%’ > ‘+’
c) ‘*’ > ‘/’ > ‘%’ > ‘+’
d) ‘%’ > ‘*’ > ‘/’ > ‘+’
View Answer
Answer: c
Answer: c
Explanation: Solving the expression l = (b * c) + (r * e) + 10. While from left to
right the parentheses are given preference first.
Step 1 : b * c is evaluated first inside first parentheses.
Step 2 : r * e is evaluated second on right side of first addition symbol.
Step 3 : After evaluating both parentheses 10 is added to value of both.
Output : My name.
Answer: c
Explanation: This += is known as short hand operator which is same as variable =
variable +1. Similarly, a-= 1 is a = a-1, a*=1 is a = a * 1. They are used to make
code short and efficient.
Answer: c
Explanation: This += is known as short hand operator which is same as variable =
variable +1. Similarly, a-= 1 is a = a-1, a*=1 is a = a * 1. They are used to make
code short and efficient.
Answer: c
Explanation: Solving the expression for b1 tests the condition for either true or
false result in ‘0’. Similarly, for ‘b2’ ‘l’ on solving gives ‘0’. So, condition is
true for bool b2 as 0 == 0. Hence, k = 0 and z = 1.
Output :
0 1.