Question 11: What will be the output of the following program?
class Person
{
public void Introduction(){
Console.WriteLine("I am a person.");
}
public string Introduction(){
return "I am a person.";
}
}
Question 12: What will be the output of the following program?
class Person
{
public void Introduction(){
Console.WriteLine("I am a person.");
}
public void Introduction(string name){
Console.WriteLine("My name is " + name);
}
public void Introduction(string name, int age = 0){
Console.WriteLine($"My name is {name} and age is {age}");
}
}
Person p = new Person();
p.Introduction("Steve");
Question 13: What will be the output of the following program?
class Person
{
public void Introduction(int age, string name){
Console.WriteLine("My name is " + name);
}
public void Introduction(string name, int age=0){
Console.WriteLine($"My name is {name} and age is {age}");
}
}
Person p = new Person();
p.Introduction("Steve");
Question 14: What will be the output of the following program?
class Person
{
public void Introduction(int age = 0, string name){
Console.WriteLine("My name is " + name);
}
public void Introduction(string name, int age=0){
Console.WriteLine($"My name is {name} and age is {age}");
}
}
Person p = new Person();
p.Introduction("Steve");
Question 15: What will be the output of the following program?
class Shape
{
public int Sides { get; set; }
}
class Square : Shape
{
}
class Program
{
public static void Display(Square s){
Console.WriteLine($"Sides: {s.Sides}");
}
public static void Main()
{
Shape sq = new Square();
Sq.Sides = 4;
Display(sq);
}
}