Multiple Choice Questions (with solutions)
May 22, 2024 (01:30:36 PM)
Why are the instructors sharing most of the material in odt, docx, pdf, html and md?
What does “free” software means?
In your IDE, the shortcut to compile your program is usually…
To share or backup a project, you need to…
If your IDE returns the message
Program.cs(21,21): Error CS0117: 'Console' does not contain a definition for 'WiteLine' (CS0117) (Solution)
This means that…
Consider the following code:
int age, defaultChoice = 0; decimal averagePrice;
Which of the following is correct?
Consider the following code:
int person = 12; int pie = 5; int piePerPerson = pie / person; .WriteLine("Each guest gets " + piePerPerson + " pie(s)."); Console
What will be displayed by it?
Consider the following statement:
decimal balance = 2.5M; decimal price = 12; decimal remainingBalance = balance - price;
Which of the following is correct?
The method used to read a string from the user is called…
Consider the following program:
.WriteLine("Enter your age."); Consolestring fromUser = Console.ReadLine(); int age = _______ (fromUser);
To correctly be able to store the string in
fromUser
into age, you should replace_______
with…What are, respectively, the return types of a constructor and of a
ToString
method?What is the name of a constructor method?
What are the three logical connectives in C# (that we studied)?
Which of the following will evaluate to true?
Will the following expression evaluates, and if so, what will it evaluate to?
true == false || 2 / 1 > 0 && 3 - 1 != 2 * 0.5 + 0.5
evaluates?
What will be displayed by the following code?
int number = 10; while (number <= 15) { +=2; number.Write(number + " "); Console}
What will be displayed by the following code?
int i = 0; while(i < 10) { .WriteLine(i); Console}
Consider the following code:
.WriteLine("Enter… something!"); Consoleint answer; bool valid = int.TryParse(Console.ReadLine(), out answer); .WriteLine($"returns: {valid}, value:{answer}"); Console
If the user enters “Train”, then it will display:
Consider the following code:
string answer; .WriteLine("Enter something"); Console= Console.ReadLine(); answer while (answer != "yes" || answer !="Yes"){ .WriteLine("Enter something"); Console= Console.ReadLine(); answer }
What can the user enters to exit this loop:
Consider the following code:
int answer; .WriteLine("Enter something"); Console= int.Parse(Console.ReadLine()); answer while (answer > 10 && answer < 100){ .WriteLine("Enter something"); Console= int.Parse(Console.ReadLine()); answer }
What can the user enters to exit this loop?
What is the correct way of creating an array of
int
of size 5 namedmyArray
?Consider the following code:
int[] grades = {10, 20, 5, 15}; .WriteLine(grades[2]); Console
What will it display?
Consider the following code:
char[] grades = {'A', 'B', 'C', 'D', 'F'}; int i = 0; while(i < grades.Length){ ++; i.WriteLine(grades[i]); Console}
Something is wrong with it, can you tell what?
What will be displayed by the following code?
for (int e = -5; e <= 20; e += 5) { .Write(e + " "); Console}
What will be displayed by the following code?
int variable = 0; for (int e = 1; e <= 5; e += 1) { += e; variable } .WriteLine(variable); Console