C# .NET quiz questions

C# .NET interview questions

  • 1.

    PLINQ is an extension to LINQ to run queries in parallel.

    1. True

    2. False

    Answer
  • 2.

    The Parallel class can not be used to run code in parallel.

    1. True

    2. False

    Answer
  • 3.

    A Task object encapsulates a job that needs to be executed. Tasks are the recommended way to create multithreaded code.

    1. True

    2. False

    Answer
  • 4.

    The Thread class can be used if you want to create your own threads explicitly. Otherwise, you can use the ThreadPool to queue work and let the runtime handle things.

    1. True

    2. False

    Answer
  • 5.

    Using multiple threads can neither improve responsiveness, nor enable you to make use of multiple processors

    1. True

    2. False

    Answer
  • 6.

    A thread can be seen as a virtualized CPU

    1. True

    2. False

    Answer
  • 7.

    What is the ouput?

    int integerNumber;
    integerNumber = 17843;
    Console.WriteLine(integerNumber.ToString("F", 
                            CultureInfo.InvariantCulture));

     

    1. 17843

    2. 17843.0

    3. 17843.00

    4. 17843.000

    Answer
  • 8.

    What is the output?

    double value = 12345.6789;
    Console.WriteLine(value.ToString("E10", CultureInfo.InvariantCulture));

     

    1. 1.2345678900E+004
    2. 1.2345678900E004
    3. 1.23456789E+004
    Answer
  • 9.

    What is the output?

    double value = 12345.6789;
    Console.WriteLine(value.ToString("E", CultureInfo.InvariantCulture));

     

    1. 1.234568E004

    2. 1.234568E+004

    3. 1234.568E+004

    Answer
  • 10.

    What is the output?

    int value; 
          
    value = 12345;
    Console.WriteLine(value.ToString("D"));

     

    1. 12,345

    2. 12.345

    3. 12345

    4. Invalid formatting

    Answer
  • 11.

    What is the result?

    decimal value = 123.456m;
    Console.WriteLine("Your account balance is {0:C2}.", value);
    1. Your account balance is $123.46.

    2. Your account balance is 123.46$.

    3. Your account balance is 123.46.

    4. Your account balance is USD 123.46.

    Answer
  • 12.

    What is the output?

    DateTime dat = new DateTime(2017, 1, 17, 9, 30, 0); 
    string city = "Chicago";
    int temp = -16;
    string output = String.Format("At {0} in {1}, the temperature was {2} degrees.",
                                  dat, city, temp);
    Console.WriteLine(output);

     

    1. At 17/01/2017 9:30:00 AM in Chicago, the temperature was -16 degrees.

    2. At 01/17/2017 9:30:00 AM in Chicago, the temperature was -16 degrees.

    3. At 1/17/2017 9:30:00 AM in Chicago, the temperature was -16 degrees.

    4. At 01/17/2017 9:30:00 AM in Chicago, the temperature was -16 degrees.

    Answer
  • 13.

    What is the output?

    int[] years = { 2013, 2014, 2015 };
    int[] population = { 1025632, 1105967, 1148203 };
    String s = String.Format("{0,-10} {1,-10}\n\n", "Year", "Population");
    for(int index = 0; index < years.Length; index++)
       s += String.Format("{0,-10} {1,-10:N0}\n",
                          years[index], population[index]);

     

    1. Year       Population
      
      2013       1,025,632
      2014       1,148,203
      2015       1,105,967

       

    2. Year       Population
      
      2013       1,148,203
      2014       1,105,967
      2015       1,025,632

       

    3. Year       Population
      
      2013       1,025,632
      2014       1,105,967
      2015       1,148,203

       

    4. Invalid formatting

    Answer
  • 14.

    What is the valid result of s?

    string s = String.Format("It is now {0:d} at {0:t}", DateTime.Now);

     

    1. It is now 4/10/2016 at 10:04 AM GMT
    2. It is now 4/10/2016 at 10:04 AM UTC
    3. It is now 4/10/2016 at 10:04 AM
    Answer
  • 15.

    What is the result?

    Decimal pricePerOunce = 17.36m;
    String s = String.Format("The current price is {0:C2} per ounce.",
                             pricePerOunce);
    1. The current price is 17.36 per ounce.
    2. The current price is $17.36 per ounce.
    3. The current price is $17.36m per ounce.
    Answer
  • 16.

    What is the result?

    Decimal pricePerOunce = 17.36m;
    String s = String.Format("The current price is {0} per ounce.",
                             pricePerOunce);

     

    1. The current price is 17.36 per ounce.

    2. The current price is 17.36m per ounce.

    3. Exception thown

    Answer
  • 17.

    What is the output?

    @{
        var outsideTemp = 79;
        var weatherMessage = "Hello, it is " + outsideTemp + " degrees.";
    }
    

    Today's weather: @weatherMessage

     

    1. Today's weather: Hello, it is 79 degrees.

    2. Today's weather: 79 degrees.

    3. Error

    Answer
  • 18.
    Select valid code statements and code blocks​​​
    
    1. @{ var myMessage = "Hello World"; }
    2. The value of myMessage is: @myMessage
    3. @{
          var greeting = "Welcome to our site!";
          var weekDay = DateTime.Now.DayOfWeek;
          var greetingMessage = greeting + " Today is: " + weekDay;
      }
    Answer
  • 19.

    Under which circumstances, ASP.NET routing does not handle a request even when is enabled for the Web site?

    1. A Physical File is Found that Matches the URL Pattern

    2. Routing Is Explicitly Disabled for a URL Pattern

    3. This never happen

    Answer
  • 20.

    Unhandled exceptions on thread pool threads will terminate the process

    What are they?

    1. A ThreadAbortException is thrown in a thread pool thread, because Abort was called.

    2. An AppDomainUnloadedException is thrown in a thread pool thread, because the application domain is being unloaded.

    3. The common language runtime or a host process terminates the thread.

    Answer

© 2017 QuizBucket.org