27/10/2022, 13:51 Mandatory Assignment Nr 3: Introduction to Programming and Application Design (LA E22 CBUSO1801U)
Mandatory Assignment Nr 3
Due 27 Oct at 19:00 Points 25 Questions 25
Available 27 Oct at 9:00 - 27 Oct at 19:00 10 hours Time limit 60 Minutes
Instructions
Dear Students,
The third mandatory assignment will be an online Quiz.
The quiz will be made available to you on your canvas on Thursday, 27th Oct 2022 at 0900.
The length of Quiz is 60 minutes and it holds 25 Multiple Choice Questions. The quiz will be
available til Thursday, 27th Oct 2022 at 1800. However Please note that once you start the quiz,
you only have 60 minutes to answer and you can't Pause or choose to answer later or anything
like that.
The quiz will remain active for this longer time period rather than selected one hour so that you can
flexibly choose to start solving quiz between these hours on Thursday 27th April 2022.
You have to answer 20 out of 25 questions correct to pass this mandatory assignment.
Good Luck.
Best regards,
Abid Hussain
Attempt history
Attempt Time Score
LATEST Attempt 1 49 minutes 21 out of 25
Correct answers will be available 28 Oct at 0:00 - 31 Oct at 0:00.
Score for this quiz: 21 out of 25
Submitted 27 Oct at 13:48
This attempt took 49 minutes.
Incorrect Question 1 0 / 1 pts
https://cbscanvas.instructure.com/courses/28071/quizzes/74020 1/15
27/10/2022, 13:51 Mandatory Assignment Nr 3: Introduction to Programming and Application Design (LA E22 CBUSO1801U)
What will be the output of following code statements.
static void Main(){
String studentName = "Mr Wayne";
Console.WriteLine("Hello {studentName} \nHow are you ? ");
Hello {studentName}
How are you ?
Hello Mr Wayne
How are you ?
Hello How are you ?
Incorrect
Question 2 0 / 1 pts
Following keywords are used to comment multiple lines in the code.
/* some comments */
True
False
Incorrect
Question 3 0 / 1 pts
If we use Command Console.WriteLine(). We have to add a using
System namespace otherwise program will not even compile.
https://cbscanvas.instructure.com/courses/28071/quizzes/74020 2/15
27/10/2022, 13:51 Mandatory Assignment Nr 3: Introduction to Programming and Application Design (LA E22 CBUSO1801U)
True
False
Incorrect
Question 4 0 / 1 pts
It is fine to not use using statement in the program namespace
because it is just optional.
True
False
Question 5 1 / 1 pts
If a required library is not included in a program what will happen? For
example writing Console.WriteLine(""); in the program without adding a
namespace or library.
No Error will occur and program will run fine
A compile time error will occur
Program will run with unreliable results
Question 6 1 / 1 pts
The keywords (also known as reserved words) for example
class/object/switch etc are not case sensitive ?
https://cbscanvas.instructure.com/courses/28071/quizzes/74020 3/15
27/10/2022, 13:51 Mandatory Assignment Nr 3: Introduction to Programming and Application Design (LA E22 CBUSO1801U)
True
False
Question 7 1 / 1 pts
A class can not instantiate more than one object?
True
False
Question 8 1 / 1 pts
If there is a class named Account as follows:
public class Account {
public Account(int accountId) {
AccountId = accountId;
public int AccountId { get; set; }
public String Name { get; set; }
public int Balance { get; set; }
Which of the following is/are correct syntax for instantiation of object.
Multiple answers can be correct.
https://cbscanvas.instructure.com/courses/28071/quizzes/74020 4/15
27/10/2022, 13:51 Mandatory Assignment Nr 3: Introduction to Programming and Application Design (LA E22 CBUSO1801U)
Account acc = new Account(23);
Account acc = new Account();
Account account = new Account("345");
Account = new Account(23);
Question 9 1 / 1 pts
For the following class :
public class Account {
public Account(int accountId) {
AccountId = accountId;
public Account(){}
public String AccountId { get; set; }
public String Name { get; set; }
public int Balance { get; set; }
Following statements will compile fine:
var account = new Account();
account.Balance = 22;
True
False
https://cbscanvas.instructure.com/courses/28071/quizzes/74020 5/15
27/10/2022, 13:51 Mandatory Assignment Nr 3: Introduction to Programming and Application Design (LA E22 CBUSO1801U)
Question 10 1 / 1 pts
Which one of these are correct access modifiers. i.e. used to set
accessibility of a property.
public, private, personal
public, private, intern
public, private, protected
primary, public, private
Question 11 1 / 1 pts
If you declare a method private in a class. What happens when you try
access that method in another class where you use that method.
//for example code for class:
public class Account{
private void CalculateSalary() {
//calculate salary here
//example code for using the class
Account acc = new Account();
acc.CalculateSalary(); // this is line of concern in this question
https://cbscanvas.instructure.com/courses/28071/quizzes/74020 6/15
27/10/2022, 13:51 Mandatory Assignment Nr 3: Introduction to Programming and Application Design (LA E22 CBUSO1801U)
The proram will run without result
The program will not find the method and give an error at compile time
The program will automatically change the method access modifier to
public
The program will add more properties automatically
Question 12 1 / 1 pts
Every instance (object) of a class uses own memory and stores
separate variable values for each instance (object) of that class?
for exampe for a class Account if we have following objects.
Account acc1 = new Account();
Account acc2 = new Account();
True
False
Question 13 1 / 1 pts
The following code output will be :
int myVal = 20;
if(myVal > 10)
{ Console.WriteLine($"Is bigger than 10: {myVal > 10}"); }
https://cbscanvas.instructure.com/courses/28071/quizzes/74020 7/15
27/10/2022, 13:51 Mandatory Assignment Nr 3: Introduction to Programming and Application Design (LA E22 CBUSO1801U)
Is bigger than 10: 20 > 10
No outout and compiler error
Is bigger than 10: true
Question 14 1 / 1 pts
Please select the correct output of the following code:
int val1 = 20;
int val2 = 44;
if((val1 >= 20) && (val2 <= 44)) {
Console.Write("condition 1 met");
val2 = 0;
if(val2 > 0 || val1 < 21 ) {
Console.Write("condition 2 met");
condition 1 met
condition 2 met
condition 1 met
condition 2 met
condition 1 metcondition 2 met
https://cbscanvas.instructure.com/courses/28071/quizzes/74020 8/15
27/10/2022, 13:51 Mandatory Assignment Nr 3: Introduction to Programming and Application Design (LA E22 CBUSO1801U)
Question 15 1 / 1 pts
Please select the correct output of the following code:
int val1 = 10;
int val2 = 34;
if((val1 >= 10) && (val2 <= 40)) {
Console.Write("condition 1 met");
}
else if(val2 > 0 || val1 < 21 ) {
Console.Write("condition 2 met");
}
else {
Console.Write("Hello there");
}
condition 1 met
condition 1 met
condition 2 met
condition 1 metcondition 2 met
condition 2 met
Question 16 1 / 1 pts
Please select correct output of the code:
bool val1 = false;
bool val2 = true;
if (val1)
{
https://cbscanvas.instructure.com/courses/28071/quizzes/74020 9/15
27/10/2022, 13:51 Mandatory Assignment Nr 3: Introduction to Programming and Application Design (LA E22 CBUSO1801U)
Console.Write("Value 1");
}
else
{
Console.Write("Value 2");
}
Value 2
Value 1
Value 1
Value 2
Null
Question 17 1 / 1 pts
Please select correct output of the code:
int counter = 0;
while (counter < 5)
{
Console.Write(counter);
counter++;
}
012345
01234
12345
024
https://cbscanvas.instructure.com/courses/28071/quizzes/74020 10/15
27/10/2022, 13:51 Mandatory Assignment Nr 3: Introduction to Programming and Application Design (LA E22 CBUSO1801U)
Question 18 1 / 1 pts
Please select correct output of the following code:
int counter = 5;
do
{
Console.WriteLine(counter);
}
while (counter < 0);
54321
43210
543210
Question 19 1 / 1 pts
Please select the correct output of the code:
for(int i = 1; i <= 10; i = i + 5)
{
Console.Write(i);
}
0510
0123456789
12345678910
https://cbscanvas.instructure.com/courses/28071/quizzes/74020 11/15
27/10/2022, 13:51 Mandatory Assignment Nr 3: Introduction to Programming and Application Design (LA E22 CBUSO1801U)
16
Question 20 1 / 1 pts
Please select the output of the following code:
string state = "NY";
switch (state)
{
case "NY":
Console.WriteLine("State is New York");
break;
case "NJ":
Console.WriteLine("State is New Jersey");
break;
case "PA":
Console.WriteLine("State is Pennysylvania");
break;
default:
Console.WriteLine("State is unknown");
break;
}
State is New York
State in unknown
State in unknown
State in New York
State is New Jersey
Question 21 1 / 1 pts
https://cbscanvas.instructure.com/courses/28071/quizzes/74020 12/15
27/10/2022, 13:51 Mandatory Assignment Nr 3: Introduction to Programming and Application Design (LA E22 CBUSO1801U)
Correct syntax to initialise an Array of Integer for 10 elements
int[9] myArray = new int[];
int[10] myArray = new int[10];
int[] myArray = new int[10];
int[] myArray = new int[9];
Question 22 1 / 1 pts
What will be output of the following code:
int[] myArray = {4,5,7,9,1,0};
Console.WriteLine(myArray[3]);
Question 23 1 / 1 pts
What will be output of the following :
https://cbscanvas.instructure.com/courses/28071/quizzes/74020 13/15
27/10/2022, 13:51 Mandatory Assignment Nr 3: Introduction to Programming and Application Design (LA E22 CBUSO1801U)
string[] arr = {"Apple", "Banana", "Orange", "Melon", "Water Melon"};
for(int i = 0;i<arr.Length;i+=2){
Console.Write(arr[i]);
}
AppleBananaOrange
AppleOrangeWater Melon
AppleWaterMelon
BananaMelon
Question 24 1 / 1 pts
A class can have maximum 3 constructors.
True
False
Question 25 1 / 1 pts
If a class has no constructor defined then empty constructor is
available by default?
True
False
https://cbscanvas.instructure.com/courses/28071/quizzes/74020 14/15
27/10/2022, 13:51 Mandatory Assignment Nr 3: Introduction to Programming and Application Design (LA E22 CBUSO1801U)
Quiz score: 21 out of 25
https://cbscanvas.instructure.com/courses/28071/quizzes/74020 15/15