VS 2019 Beginner

1. What is One-click code cleanup in Visual Studio ? 
A feature that allows you to apply a code style with one click.
2. Can you initiate a debugging session from a computer that is participating, but hasn't started, a Live Share Session ?
Yes
3. What can you do with the **New Search** functionality in VS ?
Almost search anything that you can do in VS.
4. What are the solution filters in Visual studio ?
a file format that contains a certain view of a solution.
5. How can you increase the performance of the search functionality in the watch and locals windows in Visual Studio ?
By decreasing the search depth.
6. How can you share code styles and rules with your team ?
By exporting them as an .editorconfig file.
7. How can you make sure that all members of your team have the same workloads and features of visual studio installed ?
By exporting and sharing the installation configuration settings.
8. What is GitHub Pull Request ?
9. One click Code Cleanup ?
10. .editorconfig file ?
11. What is intellicode ?
12. Visual studio live share ?
13 . string fact = "Life is too short to...always remove the USB drive safely";

int start = fact.IndexOf("always");

var fact2 = fact.Substring(start);

14. What will be the result of the following code? 
public record Person  {
public string FirstName { get; init; }
public string LastName { get; init; }
}
public class MyClass {
public static void Main(string[] args) {
var person = new Person { FirstName = "First", LastName = "Last" };
person.LastName = "Middle";
System.Diagnostics.Debug.WriteLine(person.FirstName + " " + person.LastName);
}
}
There will be a syntax error because Person is immutable and cannot be changed.

15. he following demonstrates instantiating an Action<T> delegate:
public class TestAction1
{
public static void Main()
{
Action<string> messageTarget;
messageTarget = ShowWindowsMessage;
messageTarget("Hello, World!");
}

private static void ShowWindowsMessage(string message)
{
MessageBox.Show(message);
}
}

What is true of using Action<T> as a variable?


It simplifies this code by instantiating the Action<T> delegate instead of explicitly defining a new delegate and assigning a named method to it.


16. 

You wrote a class MyClass that overrides a base class method virtual void DoSomething(). How can you prevent the MyClass override of DoSomething from being further overridden?
You can declare the method DoSomething as sealed override.

17. 

Which loop statement will produce a value of 25 in the Console.WriteLine() statement at the bottom?
A . 
int x;
while (x == 0 || x < 26)
{
    x++;
}
Console.WriteLine("x: " + x);


B .
int x = 1;
do
{
    x++;
} while (x <= 25);
Console.WriteLine("x: " + x);

C .
int x = 1;
do
{
    x++;
} while (x < 25);
Console.WriteLine("x: " + x);

D . 
int x = 1;
while (x <= 25)
{
    x++;
}
Console.WriteLine("x: " + x);

Ans : C.

18.  You can declare the method DoSomething as sealed override.

Which is an example of a reusable base class?
A. private static int GetNumber();
B. -interface IInterface
C. -sealed class myClassA : myClassB
D. -System.Windows.Forms.Button

Ans : D

19. What does the following line of code represent?
var unixTimestamp =
(Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

Ans :  The number of seconds between the Unix epoch and the current Coordinated Universal Time (UTC).

20. Which primitive type would be able to hold the number 55,000?
A   sbyte
B   byte
C   short
D   ushort

Ans : D

21. What sequence of characters indicates the start of an XML-style documentation comment in C# code?

Ans : ///

22.  What value will the following code display on the console? int i;
for (i = 0; i < 10; i++)
{
}
Console.WriteLine(i);

A  - 0
B  - 9
C  - 10
D  - 1

23. You wrote two classes called ErrorLog and ErrorLogSerializer. What could you do if you wanted the ErrorLogSerializer to access private fields inside the ErrorLog class?

A. Declare ErrorLog as a nested class inside ErrorLogSerializer.
B. In ErrorLog, declare that ErrorLogSerializer is a friend class of ErrorLog by declaring it friend.
C. Declare ErrorLogSerializer as a nested class inside ErrorLog.
D. In ErrorLogSerializer, declare that ErrorLog is a friend class of ErrorLogSerializer by declaring it friend.

Ans : C

24. Review the following declaration of a generic class:
public class Employees<T> where T : Employee, new()
{
//implementation
}

What does new()

indicate in this context?
 
A. The constraint will always check to see if there is a default constructor.
B. The constraint will not accept instances of the Employee class that isn't initialized.
C. The Employees<T> must be initialized at the time of declaration.
D.  All Employee objects must have required values set.

Ans : A

No comments:

Post a Comment

Pages