C# (pronounced "C-sharp") is a programming language developed by Microsoft in 2000. It is designed for building Windows desktop applications and games, but it can also be used to develop web and mobile applications, as well as games for other platforms like Xbox and Windows Phone. C# is a modern, object-oriented language that is similar to Java and C++ in terms of syntax and structure. It is part of the .NET framework and can be used in conjunction with other languages in the .NET ecosystem, such as F# and Visual Basic. C# is widely used for building enterprise applications, web services, and games, and is considered a powerful and versatile language for developing a wide range of software.
1. What is most accurate description of a regular expression?
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 patters.
A regular expression allows a variable to be passed by reference.
2. Why would you use a class field in C#
To communicate between classes and object
To define behaviours of the class
To hold information and data contained in the class object
To store the class definition value
3. When would you use generics in your code?
when code reuse is a priority
when type safety is important
to increase code performance
all of these answers
4. 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
Login successful... Valid user!
5. How would you declare a sealed class named User?
abstract User {}
sealed class User
private sealed class User
public class User
6. What is the correct way to write an event named apiResult based on a delegate named ResultCallback?
public event void ResultCallback
public event ResultCallback apiResult;
public void event ResultCallback apiResult;
public event ResultCallback(() -> apiResult);
7. When will the code inside finally block be executed in a try-catch statement?
after the try and catch blocks
when the finally block overrides the catch block and executes in its place
if there is an error, it won't execute at all
between the try and catch blocks
8. What method correctly extends the string class?
public static void IsvalidName(this string i, string value) {}
public string IsvalidName(this string i, string value) {}
public static string IsvalidName(this string i, string value) {}
public void IsvalidName(this string i, string value) {}
9. How are C# classses limited?
They support multiple inheritance.
They can have only a set number of properties.
They do not support multiple inheritance.
They can have only a set number of methods.
10. What function do namespaces perform?
Namespaces calculate code coverage at runtime.
Namespaces separate code into groupings, control access, and void naming collisions.
Namespaces compile application code together at compile time.
Namespaces group code together into a single repository.
11. 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 can be used only as base class
a class that is denoted by the virtual keyword
12. When using a thread pool what happens to a given thread after it finishes its task?
The thread goes inactive in the background and waits for garbage collection.
The thread returns to the pool for reuse.
The thread is destroyed and memory is freed up.
The thread runs in loop until the next assignment.
13. 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
14. What does operator overloading allow you to do?
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
hide built-in operatores when necessary
add methods to be interpreted by the compiler at runtime
15. What it the main purpose of LINQ?
to delete duplicate data
to bind namespaces and assemblies
to query and transform data
to connect assemblies
16. 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);
17. What is the difference between throw exceptions and throw clauses?
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.
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.
18. 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 wait keyword is missing from the end of the method.
The yield keyword is missing from the method.
The return yield statement is missing at the end of the method.
The method is missing an await keyword in its body.
19. What are C# events?
system actions that communicate directly with the compiler at runtime
actions that generate notifications, which are sent to their registered listeners
user-only methods that send data to the application's back end
actions that execute when the code compiles, generating logs and test output
20. What kind of values can arrays store?
unordered collections of numerc values
multiple variables, or collections, of the same type
key-value pairs of any C# supported type
class and struct instances
27. In which of these situations are interfaces better than abstract classes?
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.
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.
28. Which statement is true of delegates?
They cannot be used as callbacks.
Delegates are not supported in the current version of C#
Only variables can be passed to delegates as parameters.
They can be chained together.
29. Which choice best defines C#'s asynchronous programming model?
inherited callback
task-based
Callback-based
reactive
30. How would you determine if a class has a particular attribute?
var type = typeof(SomeType);
var attribute = type.GetCustomAttribute<SomeAttribute>();
var typeof(MyPresentationModel).Should().BeDecoratedWith<SomeAttribute>();
Attribute.GetCustomAttribute, typeof(SubControllerActionToViewDataAttribute)
Attribute.GetCustomAttribute(typeof(ExampleController), typeof(SubControllerActionToViewDataAttribute))
31. What is the difference between the ref and out keywords?
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.
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.
32. How could you retrieve information about a class, as well as create an instance at runtime?
abstraction
dependency injection
reflection
serialization
33. What is this code an example of?
private static object objA;
private static object objB;
private static void performTaskA()
{
lock (objB)
{
Thread.Sleep(1000);
lock (objA) { }
}
}
private static void PerformTaskB()
{
lock (objA)
{
lock (objB) { }
}
}
thread mismanagement
a potential deadlock
a private class that uses multithreading
multithread coding
34. What is the difference between an anonymous type and a regular data type?
Anonymous types can only be static
Anonymous types can be used only in struts
Anonymous types don't have type names
Anonymous types don't work with LINQ.
35. When would you use a Dictionary rather that an Array type in your application?
when you need to store key-value pairs rather than single values
when you need an ordered, searchable list
when you need a jagged collection structure
when you need to store values of the same type
36. What is the difference between a.Equals(b) and a == b?
The .Equals method compares contents while == compares references reference identity.
The .Equals method compares reference type while == compares primitive value types.
The .Equals method compares reference identities while the == compares contents.
The .Equals method compares primitive values while == compares all values.
37. 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
38. How does the async keyword work?
It allows the await keyword to be used in a method
It allows access to synchronous methods in the C# API
It allows access to asynchronous methods in the C# API
It allows thread pooling and synchronous processes in static classes.
39. 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
40. 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 };
41. What will be returned when this method is executed?
public void userInput(string charParamters) { }
a string variable
an integer
nothing
a Boolean
42. 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);
}
first in, first out
ascending
unordered
descending
43. Lambda expressions are often used in tandem with which of the following?
Namespaces
LINQ
Type Aliasing
Assemblies
44. What is the correct formatting for single line and multiline comments?
// - Single Line / - Multiline
// Multiline /_ Single Line _/
//* Multiline / Single Line
// Single Line /_ Multiline _/
45. How do you make a method in an abstract class overridable?
Make it static
Make it private
Make it virtual
Make it public
46. 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; }
47. Given this enumeration, how would you access the integer-type value of 'AppState.Loading'?
enum AppState { OffLine, Loading, Ready }
int currentState = (int)AppState.Loading;
string currentState = (string)AppState.Loading;
string currentState = AppState.Loading.integralVal;
int currentState = AppState.Loading.rawValue;
48. What character would you use to start a regular expression pattern at a word boundary?
d
\a
\b
\w
49. To conform to the following interface, which of its members need to be implemented?
public interface INameble
{
string FirstName { get; set; }
string LastName { get; }
}
Only the LastName property needs to be implemented.
Only the FirstName property needs to be implemented.
Both the FirstName and LastName properties need to be implemented.
Neither, they are both optional.
50. 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
51. What is the correct syntax for a new generic list of strings named contacts?
public List<string names> contacts = new List<string names>();
var contacts = new List<string>();
var contacts = new List(string);
public List(string names) contacts = new List(string names);
52. What is the difference between non-static and static classes?
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 need to be initialized before use, while static classes do not
non-static classes do not need to be initialized while static classes do
53. Which characteristic prevents this code from compiling?
public int age="28"
type safety
single inheritance
dependency injection
multiple inheritance
54. How would you serialize this class?
public class User {}
Mark the User class with the SerializableAttribute attribute.
Declare the class as private serializable class User {}.
Mark the User class with the DeserializableAttribute.
Declare the class as public serializable class User {}.
55. 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 delegate void ResultCallback<(int) responseCode>;
public void delegate ResultCallback;
56. What is the difference between a static and non-static method?
static methods do not have to instantiate an instance of the class to call the method
static methods always have to be public
non-static methods always need to have a void return type
non-static methods do not have access to static member variables
57. In C#, a subroutine is called a ________.
Function
Metadata
Method
Managed code
58. What is the Size of ‘Char’ datatype?
8 bit
12 bit
16 bit
20 bit
59. What will be the output of the following C# code?
static void Main(string[] args)
{
string s1 = "Delhi";
string s2;
s2 = s1.Insert (6, "Jaipur");
Console.WriteLine(s2);
}
DelhJaipuri
Delhi Jaipur
Delhi
DelhiJaipur
Fiverr Analytical Skill Test Answers - New!
GoogleSkillShop
GoogleSkills
MedicalQuiz
MicroSoftTests
GIT (Global information Tracker) Assessment Test Answers - New!
How to pass Javascript Linkedin Test Question and Answers - New!
Linkedin MS Azure Test Question Answers
Linkedin Microsoft Excel Test Question Answers
Linkedin Microsoft Word Test Solved Question and Answers
Linkedin Power Point Test Question Answers
Linkedin Sharepoint Test Questions and Answers
MATLAB Assessment Questions and Answers - New!
Microsoft Access Linkedin Skill Test Question Answers
Microsoft Outlook Skill Test Question and answers
Microsoft Power BI Linkedin Skill Test Question Answers