The Unbeatable Quiz On C# Test

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Bstrick
B
Bstrick
Community Contributor
Quizzes Created: 1 | Total Attempts: 1,250
Questions: 9 | Attempts: 1,250

SettingsSettingsSettings
The Unbeatable Quiz On C# Test - Quiz

Do you consider yourself to be a programming wiz? If you said yes then the quiz below is perfect to test just how awesome you are at programming. The quiz is unbeatable and if you achieve to best it, are a true genius. All the best and let’s see what you’ve got.


Questions and Answers
  • 1. 

    Does c# support multiple inheritance?

    • A.

      Yes

    • B.

      No

    Correct Answer
    B. No
    Explanation
    Multiple inheritance is not supported. To achieve this, use interfaces.

    Rate this question:

  • 2. 

    How do you keep your classes from being inherited or used as a base class?

    • A.

      Declare the class as Virtual

    • B.

      Declare the class as Private

    • C.

      Declare the class as Sealed

    • D.

      Declare the class as Internal

    • E.

      None of the above

    Correct Answer
    C. Declare the class as Sealed
    Explanation
    Sealed. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName.

    Rate this question:

  • 3. 

    Can you inherit from multiple interfaces?

    • A.

      Yes

    • B.

      No

    Correct Answer
    A. Yes
    Explanation
    Yes, it is possible to inherit from multiple interfaces in programming languages that support multiple inheritance. This allows a class to inherit and implement the methods and properties defined in multiple interfaces, providing flexibility and the ability to fulfill multiple contracts. This feature is commonly used to achieve code reusability and to create more modular and flexible code structures.

    Rate this question:

  • 4. 

    Which is true about the accessibility modifiers of methods within an Interface?

    • A.

      They are all declared as public by default

    • B.

      They are all declared as private by default

    • C.

      They are all declared as virtual by default

    • D.

      They are all declared as internal by default

    • E.

      They are all declared as sealed by default

    Correct Answer
    A. They are all declared as public by default
    Explanation
    The accessibility modifiers of methods within an Interface are all declared as public by default. This means that all methods within an Interface can be accessed and called from any other class or interface. There is no need to explicitly specify the public modifier for methods within an Interface as it is automatically assumed.

    Rate this question:

  • 5. 

    What are the different ways to overload a method?

    • A.

      Different parameter names

    • B.

      Different parameter data types

    • C.

      Different number of parameters

    • D.

      Different ordering of parameters

    • E.

      Changing the method name

    Correct Answer(s)
    B. Different parameter data types
    C. Different number of parameters
    D. Different ordering of parameters
    Explanation
    The different ways to overload a method include using different parameter data types, different number of parameters, and different ordering of parameters. Overloading a method allows for multiple methods with the same name but different parameters, providing flexibility and versatility in method usage. By using different parameter data types, different number of parameters, or different ordering of parameters, we can create different versions of the method that can be called based on the specific arguments provided. This allows for more efficient and concise code, as well as accommodating various input scenarios.

    Rate this question:

  • 6. 

    What is the difference between the System.String and System.StringBuilder class?

    • A.

      System.StringBuilder is immutable and System.String is mutable

    • B.

      System.StringBuilder is mutable and System.String is immutable

    • C.

      System.StringBuilder is a based on a class and System.String is based on a struct

    Correct Answer
    B. System.StringBuilder is mutable and System.String is immutable
    Explanation
    The correct answer is that System.StringBuilder is mutable and System.String is immutable. This means that the value of a System.String object cannot be changed after it is created, while a System.StringBuilder object can be modified.

    Rate this question:

  • 7. 

    Structs are passed by Reference?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    Structs cannot be inherited.
    Structs are passed by value, not by reference.
    Struct is stored on the stack, not the heap.

    Rate this question:

  • 8. 

    You have variable of type string name strValue. What are some of the ways this can be converted to a int?

    • A.

      Int.convert(strValue)

    • B.

      Convert.ToInt32(strValue)

    • C.

      Int32.Parse(strValue)

    • D.

      Int.value

    • E.

      Bool result = int32.TryParse(strValue, out i)

    Correct Answer(s)
    B. Convert.ToInt32(strValue)
    C. Int32.Parse(strValue)
    E. Bool result = int32.TryParse(strValue, out i)
    Explanation
    The given answer lists three methods to convert a string to an integer: Convert.ToInt32(strValue), int32.Parse(strValue), and bool result = int32.TryParse(strValue, out i).

    Convert.ToInt32(strValue) is a method in C# that converts the specified string representation of a number to an equivalent 32-bit signed integer.

    int32.Parse(strValue) is another method in C# that converts the string representation of a number to its 32-bit signed integer equivalent.

    int32.TryParse(strValue, out i) is a method in C# that attempts to convert the string representation of a number to its 32-bit signed integer equivalent. It returns a boolean value indicating whether the conversion succeeded or failed, and the converted value is assigned to the out parameter 'i'.

    Rate this question:

  • 9. 

    How do you enforce garbage collection in .NET?

    • A.

      Garbage.Collect()

    • B.

      Collect()

    • C.

      This.Collect.Garbage()

    • D.

      System.GC.Collect()

    Correct Answer
    D. System.GC.Collect()
    Explanation
    In .NET, the System.GC.Collect() method is used to enforce garbage collection. This method forces an immediate garbage collection of all generations. It can be called explicitly to free up memory and reclaim resources that are no longer needed. The other options mentioned, Garbage.Collect(), Collect(), and this.Collect.Garbage(), are not valid methods for enforcing garbage collection in .NET.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Feb 20, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 28, 2010
    Quiz Created by
    Bstrick
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.