Programming in C# Quiz Questions and Answers

What is Boxing in C#?

Answer :
  • Both of the above.

Which keyword is used to return a value inside a method?

Answer :
  • return

The three important methods exposed by the SqlCommand object are:

Answer :
  • ExecuteScalar
  • ExecuteNonQuery
  • ExecuteReader

Which of the following statements is correct about Interfaces used in C#.NET?

Answer :
  • Interfaces can be inherited.

Which of the following is an ordered collection class?

Answer :
  • Stack

Which of the following utilities can be used to compile managed assemblies into processor-specific native code?

Answer :
  • ngen

Which of the following .NET components can be used to remove unused references from the managed heap?

Answer :
  • Garbage Collector

How to do typecasting for float variables?

Answer :
  • int balance = (int) (float)amountRef;

You are creating a console application by using C#. You need to access the application assembly. Which code segment should you use?

Answer :
  • Assembly.GetExecutingAssembly();

You are developing an application that will transmit large amounts of data between a client computer and a server. You need to ensure the validity of the data by using a cryptographic hashing algorithm. Which algorithm should you use?

Answer :
  • HMACSHA256