.net full stack foundation coursera week 2 answers
C# Basics - Practice Quiz
1. What is C#?
- A markup language for web development
- A programming language for developing applications on the .NET framework
- An operating system for mobile devices
- A scripting language for browser automation
3. How do you execute C# code?
- By saving the code in a text file and opening it in a web browser
- By running the code in a command-line interface
- By compiling the code and then running the resulting executable file
- By running the code in an integrated development environment (IDE)
4. What is Visual Studio?
- A programming language
- A command-line interface for executing C# code
- An IDE for developing applications on the .NET framework
- An operating system for Windows-based applications
5. What is a variable in C#?
- A fixed value that cannot be changed during program execution
- A named memory location used to store a value that can be modified during program execution
- A named memory location used to store a value that can be modified during program execution, and has a specific data type
- A named function used to perform a specific operation
Conditional Statements - Practice Quiz
6. Which of the following operators has the highest precedence in C#?
- &&
- ==
- ++
- () (Correct Answer)
7. What is the result of the following code?
int x = 10;
int y = 20;
int z = x + y * 2;
- 50
- 60
- 40
- 30
8. What is the syntax for a do-while loop in C#?
- do { } while ();
- while { } do ();
- for { } while ();
- do { } while (condition);
9. What is the output of the following code?
int x = 5;
int y = 10;
if (x == y)
{
Console.WriteLine("x equals y");
}
else if (x > y)
{
Console.WriteLine("x is greater than y");
}
else
{
Console.WriteLine("y is greater than x");
}
- x equals y
- x is greater than y
- y is greater than x
- No output is generated.
10. What is the difference between a while loop and a do..while loop?
- There is no difference between a while loop and a do..while loop.
- A while loop checks the condition before executing the loop body, while a do..while loop checks the condition after executing the loop body at least once.
- A while loop executes the loop body a specified number of times, while a do..while loop executes the loop body an unspecified number of times.
- A while loop and a do..while loop are completely interchangeable and can be used interchangeably in any situation.