Arrays And Strings In C Sharp - Study Mode

[#81] What will be the output of the following C# code? class math
{
public int a,b

public math(int i, int j)
{
a = i

b = j

}
public void sum(math m)
{
m.a *= 2

m.b += 2

}
}
class Program
{
static void Main(string[] args)
{
math t = new math(20, 10)

t.sum(t)

Console.WriteLine(t.a + " " + t.b)

Console.ReadLine()

}
}
Correct Answer

(C) 40, 12

[#82] What will be the output of the following C# code? class Program
{
static void Main(string[] args)
{
String c = "i love Csharp"
bool a
a = c.StartsWith("I")
Console.WriteLine(a)
Console.ReadLine()
}
}
Correct Answer

(B) false

[#83] What will be the output of the following C# code? class Program
{
static void Main(string[] args)
{
int i = 5
int j
method1(ref i)
method2(out j)
Console.writeline(i + " " + j)
}
static void method1(ref int x)
{
x = x + x
}
static void method2(out int x)
{
x = 6
x = x * x
}
}
Correct Answer

(B) 10, 36

[#84] Which is the correct way of defining and initializing an array of 3 integers?
Correct Answer

(D) int[] a a = new int[3]{78, 9, 54}

[#85] What will be the output of the following C# code? static void main(string[] args)
{
int n = 1
method(n)
console.Writeline(n)
method1(ref n)
console.Writeline(n)
}
static void method(int num)
{
num += 20
console.writeline(num)
}
static void method1(ref int num)
{
num += 20
console.writeline(num)
}
Correct Answer

(B) 21 1 21 21