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);
}
}
Question 16: What will be the output of the following program?
class Printer
{
public virtual void Install()
{
Console.WriteLine("Printer Installed.");
}
public virtual void Print(string text)
{
Console.WriteLine("Printing: " + text);
}
}
class LaserPrinter : Printer
{
public override void Install()
{
Console.WriteLine("Laser Printer Installed Successfully.");
}
public void InstallDrivers()
{
Console.WriteLine("Drivers for Laser Printer Installed.");
}
}
Printer prnt = new LaserPrinter();
prnt.Install();
Question 17: What will be the output of the following program?
class Printer
{
public virtual void Install()
{
Console.WriteLine("Printer Installed.");
}
public virtual void Print(string text)
{
Console.WriteLine("Printing: " + text);
}
}
class LaserPrinter : Printer
{
public void Install()
{
Console.WriteLine("Laser Printer Installed Successfully.");
}
}
Printer printer1 = new LaserPrinter();
printer1.Install();