Q-1. What is the default access modifier of the method?
Answer: Private
Q-2. What Will Be The Output Of The Following Code Snippet:
public class Program { public static void Main(string[] args) { Console.WriteLine(Math.Round(0.5)); Console.WriteLine(Math.Round(1.5)); Console.WriteLine(Math.Round(2.5)); Console.WriteLine(Math.Round(3.5)); Console.WriteLine(Math.Round(4.5)); Console.WriteLine(Math.Round(5.5)); Console.WriteLine(Math.Round(6.5)); Console.WriteLine(Math.Round(7.5)); Console.WriteLine(Math.Round(8.5)); Console.WriteLine(Math.Round(9.5)); Console.WriteLine(Math.Round(10.5)); Console.WriteLine(Math.Round(11.5)); } }
Output:
Math.Round() Method
Explanation:
You will be surprised to see the strange out. This is because of the following definition of Math.Round() method on MSDN blog.
Decimal Math.Round(Decimal d) :– Rounds a decimal value to the nearest integer, and rounds midpoint values to the nearest even number.
Q- 3: Your company uses Visual Studio .NET as its application development platform. You have recently finished development of a class named ShopList using the .NET Framework. The class will include ShopItem objects that have the public properties exhibit below:
1. Name
2. ID
3. DiscountCode
You need to enable users of the class to iterate through the ShopList collection, and to list each product’s name and ID using the foreach statement. Which of the following code segments will you use to accomplish this task?
Q-4: Which of these statements correctly declares a two-dimensional array in C#?
Q-5 : How many web.config files that can be there an ASP.NET application?
only one
more than one
only two
up to 10
Answer : more than one
Q- 6 : Code that targets the Common Language Runtime is known as
Q- 7 : In the NUnit test framework, which attribute must adorn a test class in order for it to be picked up by the NUnit GUI?
Q-8 : Can we override private virtual methods? (A) Yes (B) No
Q- 9 : What compiler switch creates an XML file from the XML comments in the files in an assembly?
Q- 10 : Which of the following are valid .NET CLR JIT performance counters?
1. Total memory used for JIT compilation
2. Average memory used for JIT compilation
3. Number of methods that failed to compile with the standard JIT
4. Percentage of processor time spent performing JIT compilation
5.Percentage of memory currently dedicated for JIT compilation
One thought on “C# Interview Questions and Answers”