Miscellaneous In C Sharp - Study Mode
[#141] What will be the output of the following C# code snippet? class Program
{
static void Main(string[] args)
{
double x = 3.14
int y = (int) Math.Abs(x)
Console.WriteLine(y)
}
}
Correct Answer
(B) 3
[#142] Which statement is correct in the following C#.NET code snippet? Stack st = new Stack()
st.Push("Csharp")
st.Push(7.3)
st.Push(8)
st.Push('b')
st.Push(true)
Correct Answer
(C) Perfectly workable code
[#143] What will be the output of the following C# code snippet? class UnsafeCode
{
unsafe static void Main()
{
int n = 10
int* p = &n
int** p1 = &p
int*** p2 = &p1
Console.WriteLine(*p * **p1 * ***p2)
Console.ReadLine()
}
}
Correct Answer
(C) program will print 1000
[#144] The correct code to access all the elements of the queue collection created using the following C#.NET code snippets? Queue q = new Queue()
q.Enqueue("Harsh")
q.Enqueue('a')
q.Enqueue(false)
q.Enqueue(70)
q.Enqueue(8.5)
Correct Answer
(A) IEnumerator e
e = q.GetEnumerator()
while(e.MoveNext())
Console.WriteLine(e.Current)
[#145] What will be the output of the following C# code snippet? class UnsafeCode
{
unsafe static void Main()
{
int a = 2
int b = 4
int *a1 = &a
int *b1 = &b
Console.WriteLine(*a1 + *b1)
}
}
Correct Answer
(A) 6