Week 8 Assignment
Week 8 Assignment
Answer all questions in just one file named StudentID.txt and submit your assignment on Moodle.
Question 1: What is displayed, and why?
using System;
class Test
{
static void Main()
{
int x = 5;
int y = ++x + x++;
Console.WriteLine(y);
}
}
class Father
{
public virtual void doIt(int x)
{
Console.WriteLine("Father.doIt(int)");
}
}
class Test
{
static void Main()
{
Son d = new Son();
int i = 10;
d.doIt(i);
}
}
Question 3: Why does this print "False"?
using System;
class Test
{
static void Main()
{
int[] array1 = { 1, 2, 3 };
int[] array2 = { 1, 2, 3 };
Console.WriteLine(areEqual);
}
}
Question 5: The bellow code uses the anonymous method. What does it do?
using System;
using System.Collections.Generic;
class Test
{
delegate void Printer();
class Test
{
enum Ooooop { Dog, Cat};
static void Main()
{
Ooooop t = 0.0;
Console.WriteLine(t);
}
}
class Test
{
static void Main()
{
Foo("Hello");
}
class Test
{
static void Main(string[] args)
{
DateTime dateTime = new DateTime(2024, 3, 1);
Console.WriteLine(dateTime); // Outputs: 3/1/2024 12:00:00 AM
dateTime.AddHours(24);
Console.WriteLine(dateTime); // Still outputs: 3/1/2024 12:00:00 AM
}
}