Output:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Question_3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Question_3.Employee E = new Question_3.Employee();
MessageBox.Show("The Value Of Default Constructor : " + E.display_employee());
}
private void button2_Click(object sender, EventArgs e)
{
Question_3.Owner O = new Question_3.Owner(40);
MessageBox.Show("The Value Of Parameterized Constructor : " + O.display_owner());
}
}
}
Employee Class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Question_3
{
public class Employee
{
int DA, HR;
public Employee()
{
DA = HR = 5;
}
public int display_employee()
{
return this.DA * this.HR;
}
}
public class Owner : Employee
{
int DA, HR, Salary;
public Owner(int HM)
{
DA = 10;
HR = HM;
Salary = DA + HM;
}
public int display_owner()
{
return Salary;
}
}
}
No comments:
Post a Comment