LinkedIn: C# (C Sharp) | Skill Assessment Quiz Solutions-2 | APDaga

▸ C# (C Sharp) | LinkedIn Skill Assessment Quiz Solutions-2

LinkedIn: C# (C Sharp) | Skill Assessment Quiz Solutions-2 | APDaga

Checkout other solutions for C# (C Sharp): Solution-1Solution-2


  1. Given this enumeration, how would you access the integer-type value of ‘AppState.Loading’?
    enum AppState { OffLine, Loading, Ready }

    • string currentState = (string)AppState.Loading;
    • string currentState = AppState.Loading.integralVal;
    • int currentState = AppState.Loading.rawValue;
    • int currentState = (int)AppState.Loading;


  1. What character would you use to start a regular expression pattern at a word boundary?

    • d
    • \a
    • \b
    • \w


  1. To conform to the following interface, which of its members need to be implemented?

    public interface INameble
    {
        string FirstName { get; set; }
        string LastName { get; }
    }
    
    • Both the FirstName and LastName properties need to be implemented.
    • Neither, they are both optional.
    • Only the LastName property needs to be implemented.
    • Only the FirstName property needs to be implemented.


  1. You’re dealing with multiple assemblies in your program, but are worried about memory allocation. At what point in the program life cycle are assemblies loaded into memory?

    • at runtime
    • at compile time
    • only when required
    • only when programmatically loaded


  1. What is most accurate description of a regular expression?

    • A regular expression is a C# tool used to parse HTML
    • A regular expression is a special text string for describing a search patters.
    • A regular expression allows a variable to be passed by reference.
    • A regular expression allows a class to conform to the Equatable protocol.




  1. Why would you use a class field in C#

    • To define behaviours of the class
    • To hold information and data contained in the class object
    • To communicate between classes and object
    • To store the class definition value


  1. When would you use generics in your code?

    • to increase code performance
    • all of these answers
    • when code reuse is a priority
    • when type safety is important


  1. What prints to the console when this code is executed?

    public delegate void AuthCallback(bool validUser);
    public static AuthCallback loginCallback : Login;
    public static void Login()
    {
        Console.WriteLine("Valid user!");
    }
    
    public static void Main(string[] args)
    {
        loginCallback(true);
    }
    
    • Login successful…
    • Valid user!
    • an error, because the method signature of Login doesn’t match the delegate //It will throw an error because you cant apply Inheritance to methods that way.
    • Login successful… Valid user!


  1. How would you declare a sealed class named User?

    • public class User
    • abstract User {}
    • sealed class User
    • private sealed class User


  1. What is the correct syntax for a new generic list of strings named contacts? (similar to Q26)

    • var contacts = new List();
    • var contacts = new List(string);
    • public List contacts = new List();
    • public List(string names) contacts = new List(string names);




  1. What is the difference between non-static and static classes?

    • non-static classes need to be initialized before use, while static classes do not
      reference
    • non-static classes are accessible only from an interface while static classes are accessible from anywhere
    • non-static classes need to initialize all class members at runtime, while static classes do not
    • non-static classes do not need to be initialized while static classes do


  1. Which characteristic prevents this code from compiling?
    public int age="28"

    • type safety
    • single inheritance
    • dependency injection
    • multiple inheritance


  1. How would you serialize this class?
    public class User {}

    • Mark the User class with the DeserializableAttribute.
    • Declare the class as public serializable class User {}.
    • Mark the User class with the SerializableAttribute attribute.
    • Declare the class as private serializable class User {}.


  1. How would you write a delegate named ResultCallback with an int parameter named responseCode

    • public delegate ResultCallback(int responseCode)
    • public delegate void ResultCallback<(int) responseCode>;
    • public void delegate ResultCallback;
    • public delegate void ResultCallback(int responseCode);


  1. What is the difference between a static and non-static method?

    • non-static methods always need to have a void return type
    • non-static methods do not have access to static member variables
    • static methods do not have to instantiate an instance of the class to call the method
    • static methods always have to be public




  1. What is the correct way to write an event named apiResult based on a delegate named ResultCallback?

    • public void event ResultCallback apiResult;
    • public event ResultCallback(() -> apiResult);
    • public event void ResultCallback
    • public event ResultCallback apiResult;


  1. When will the code inside finally block be executed in a try-catch statement?

    • if there is an error, it won’t execute at all
    • between the try and catch blocks
    • after the try and catch blocks
    • when the finally block overrides the catch block and executes in its place


  1. What method correctly extends the string class?

    • public static string IsvalidName(this string i, string value) {}
    • public static void IsvalidName(this string i, string value) {}
    • public string IsvalidName(this string i, string value) {}
    • public void IsvalidName(this string i, string value) {}


  1. How are C# classses limited?

    • They do not support multiple inheritance.
    • They support multiple inheritance.
    • They can have only a set number of properties.
    • They can have only a set number of methods.


  1. What function do namespaces perform?

    • Namespaces calculate code coverage at runtime.
    • Namespaces compile application code together at compile time.
    • Namespaces group code together into a single repository.
    • Namespaces separate code into groupings, control access, and void naming collisions.




  1. What is the correct way to write a public property with a private backing field?
  • A

    private int _password;
    pubic int Password = { get; set; }
    
  • B

    private int _password;
    public int Password = _password;
    
  • C

    private int _password;
    public int Password
    {
      get -> _password;
      set-> _password = value;
    }
    
  • D

    private int _password;
    public int Password
    {
      get { return _password; }
      set { _password = value; }
    }
    


  1. What is a thread pool?

    • a collection of synchronous methods created during initialization that cannot be reused
    • a collection of threads created during initialization that can be reused
    • a collection of threads only recognized at compile time that can be reused
    • a collection of asynchronous methods created at compile time that cannot be reused


  1. What is the most accurate description of a regular expression?

    • A regular expressions allows a variable to be passed by reference
    • A regular expression allows a class to conform to the Equatable protocol
    • A regular expression is a C# tool used to parse HTML
    • A regular expression is a special text string for describing a search pattern


  1. When an object in C# is serialized, what is it converted to?

    • XML
    • JSON
    • byte stream
    • value stream

    Reference: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/serialization/


  1. What is a delegate

    • a variable that holds a reference to a value type and its content
    • a specific value type that can be used only in callback methods
    • a type that holds a reference to a method with a particular parameter list and return type
    • a custom variable type that can be used in abstract classes

    Reference: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/delegates/




  1. What are the four keywords associated with exception handling in C#?

    • try, catch, valid, invalid
    • try, valid, finally, throw
    • try, catch, finally, throw
    • finally, throw, valid, invalid

    Reference: Tutorial Point


CREDITS: (Source)


Click here to see solutions for all HackerRank SQL practice questions.
&
Click here to see solutions for all Machine Learning Coursera Assignments.
&
Click here to see more codes for Raspberry Pi 3 and similar Family.
&
Click here to see more codes for NodeMCU ESP8266 and similar Family.
&
Click here to see more codes for Arduino Mega (ATMega 2560) and similar Family.

Feel free to ask doubts in the comment section. I will try my best to answer it.
If you find this helpful by any mean like, comment and share the post.
This is the simplest way to encourage me to keep doing such work.

Thanks & Regards,
- APDaga DumpBox
Post a Comment (0)
Previous Post Next Post