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

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

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

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


  1. In which of these situations are interfaces better than abstract classes?

    • When you need to define an object type’s characteristics, use an interface. When you need to define an object type’s capabilities, use an abstract class.
    • Interfaces are a legacy of older versions of C#, and are interchangeable with the newer abstract class feature.
    • When you need a list of capabilities and data that are classes-agnostic, use an interface. When you need a certain object type to share characteristics, use an abstract class.
    • You should use both an interface and an abstract class when defining any complex object.


  1. Which statement is true of delegates?

    • Delegates are not supported in the current version of C#
    • They cannot be used as callbacks.
    • Only variables can be passed to delegates as parameters.
    • They can be chained together.


  1. Which choice best defines C#'s asynchronous programming model?

    • reactive
    • inherited callback
    • task-based
    • callback-based


  1. How would you determine if a class has a particular attribute?

    • A
    var type = typeof(SomeType);
    var attribute = type.GetCustomAttribute<SomeAttribute>();
    
    • B
    var typeof(MyPresentationModel).Should().BeDecoratedWith<SomeAttribute>();
    
    • C
    Attribute.GetCustomAttribute, typeof(SubControllerActionToViewDataAttribute)
    
    • D
    Attribute.GetCustomAttribute(typeof(ExampleController), typeof(SubControllerActionToViewDataAttribute))
    


  1. What is the difference between the ref and out keywords?

    • Variables passed to out specify that the parameter is an output parameter, while ref specifies that a variable may be passed to a function without being initialized.
    • Variables passed to ref can be passed to a function without being initialized, while out specifies that the value is a reference value that can be changed inside the calling method.
    • Variables passed to out can be passed to a function without being initialized, while ref specifies that the value is a reference value that can be changed inside the calling method.
    • Variables passed to ref specify that the parameter is an output parameter, while out specifies that a variable may be passed to a function without being initialized.




  1. How could you retrieve information about a class, as well as create an instance at runtime?

    • reflection
    • serialization
    • abstraction
    • dependency injection


  1. What is this code an example of?

    private static object objA;
    private static object objB;
    
    private static void performTaskA()
    {
        lock (obj)
        {
            Thread.Sleep(1000);
            lock (objA) { }
        }
    }
    
    private static void PerformTaskB()
    {
        lock (objA)
        {
            lock (objB) { }
        }
    }
    
    • a private class that uses multithreading
    • multithread coding
    • thread mismanagement
    • a potential deadlock


  1. What is the difference between an anonymous type and a regular data type?

    • Anonymous types don’t have type names
    • Anonymous types can only be static
    • Anonymous types can be used only in struts
    • Anonymous types don’t work with LINQ.


  1. When would you use a Dictionary rather that an Array type in your application?

    • when you need a jagged collection structure
    • when you need to store values of the same type
    • when you need to store key-value pairs rather than single values
    • when you need an ordered, searchable list


  1. What is the difference between a.Equals(b) and a == b?

    • The .Equals method compares reference identities while the == compares contents.
    • The .Equals method compares primitive values while == compares all values.
    • The .Equals method compares contents while == compares references reference identity.
    • The .Equals method compares reference type while == compares primitive value types.




  1. Which choice best describes a deadlock situation?

    • when you try to instantiate two objects at the same time in the same class or struct
    • when you are trying to execute an action after a user event is registered
    • when simultaneous instructions are waiting on each other to finish before executing
    • when you try to execute a series of events simultaneously on multiple threads


  1. How does the async keyword work?

    • It allows access to asynchronous methods in the C# API
    • It allows thread pooling and synchronous processes in static classes.
    • It allows the await keyword to be used in a method
    • It allows access to synchronous methods in the C# API


  1. What is an object in C#?

    • a class or struct, including its variables and functions
    • a primitive data type that can be created only at compile time
    • a value type that can be used only with an abstract class
    • an instance of a class or struct that includes fields, properties, and/or methods


  1. Which code snippet declares an anonymous type named userData?

    • var<<!---->T> userData = new <<!---->T> { name = "John", age = 32 };
    • var userData = new { name = "John", age = 32 };
    • AType userData = new AType { name = "John", age = 32 };
    • Anonymous<T> userData = new Anonymous<T> { name = "John", age = 32 };


  1. What will be returned when this method is executed?
    public void userInput(string charParamters) { }

    • nothing
    • a Boolean
    • a string variable
    • an integer




  1. In what order would the employee names in this example be printed to the console?

    string[] employees = { "Joe", "Bob", "Carol", "Alice", "Will" };
    
    IEnumerable<string> employeeQuery = from person in employees
                                        orderby person
                                        select person;
    
    foreach(string employee in employeeQuery)
    {
        Console.WriteLine(employee);
    }
    
    • ascending
    • unordered
    • descending
    • first in, first out


  1. Lambda expressions are often used in tandem with which of the following?

    • Namespaces
    • LINQ
    • Type Aliasing
    • Assemblies


  1. What is the correct formatting for single line and multiline comments?
    • // - Single Line
      /
      - Multiline
    • // Multiline
      /_ Single Line _/
    • //* Multiline
      / Single Line
    • // Single Line
      /_ Multiline _/



  1. How do you make a method in an abstract class overridable?

    • Make it public
    • Make it static
    • Make it private
    • Make it virtual


  1. How would you write code for an integer property called Age with a getter and setter?

    • public int Age { get - set }
    • public int Age: get set;
    • public int Age (get, set );
    • public int Age { get; set; }




  1. What is an abstract class?

    • a class that is denoted by the class keyword (can be seen and used by any other class in the system–thus it is by default public)
    • something denoted by the abstract keyword and used system wide; if you want any program to create an object of a class you use the abstract class
    • a class that is denoted by the virtual keyword
    • a class that can be used only as base class


  1. When using a thread pool what happens to a given thread after it finishes its task?

    • The thread is destroyed and memory is freed up.
    • The thread runs in loop until the next assignment.
    • The thread goes inactive in the background and waits for garbage collection.
    • The thread returns to the pool for reuse.


  1. Which choice represents a class that inherits behavior from a base class?

    • a second base class
    • a revised class
    • a derived class
    • a parent class


  1. What does operator overloading allow you to do?

    • hide built-in operatores when necessary
    • add methods to be interpreted by the compiler at runtime
    • define how enums and other primitive value types work within the rest of the application
    • define custom functionality for common operators like addition and equality


  1. What it the main purpose of LINQ?

    • to delete duplicate data
    • to bind namespaces and assemblies
    • to query and transform data
    • to connect assemblies




  1. What is the correct syntax for a new generic list of strings named contacts?

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


  1. What is the difference between throw exceptions and throw clauses?

    • Throw clauses fire only at runtime, while throw exceptions can fire at any time.
    • Throw exceptions overwrite the stack trace, while throw clauses retain the stack information.
    • Throw clauses overwrite the stack trace, while throw exceptions retain the stack information.
    • Throw exceptions fire only at runtime, while throw clauses can fire during compile time.


  1. When an asynchronous method is executed, the code runs but nothing happens other than a compiler warning. What is most likely causing the method to not return anything?

    • The return yield statement is missing at the end of the method.
    • The method is missing an await keyword in its body.
    • The wait keyword is missing from the end of the method.
    • The yield keyword is missing from the method.


  1. What are C# events?

    • system actions that communicate directly with the compiler at runtime
    • actions that execute when the code compiles, generating logs and test output
    • actions that generate notifications, which are sent to their registered listeners** <= Correct
    • user-only methods that send data to the application’s back end


  1. What kind of values can arrays store?

    • unordered collections of numerc values
    • key-value pairs of any C# supported type
    • class and struct instances
    • multiple variables, or collections, of the same type


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