Answer to Question #15677 in C# for Zulekha

Question #15677
Create a console application. Add class ‘Account’ having variables as num (integer) name (String), bal (double), ac_code (byte). Define four different constructors to initialize these variables. Define a class ‘User’deriving from ‘account’ class. In user class add variables as group_no (int)and mail_id (string). Define three constructors for User class and within them call different parameterized constructors of Account. Can we call these base class constructors as second or last statement in User constructors? Define another class ‘Admin’. Can the User class derive from both ‘account’ and ‘Admin’ classes? How to make Class Admin such that No class can derive from it? How to make Account class such thatsome methods will not be allowed to override ?
1
Expert's answer
2012-10-02T07:39:51-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Account
{
& int num;
& string name;
& double bal;
& byte ac_code;
& public Account()
& {
num = 0;
name = "1";
& }
& public Account(int _num, string _name)
& {
num = _num;
name = _name;
& }
}
class User : Account
{
& int group_no;
& string mail_id;

& public User()
& {
group_no = 0;
mail_id = "o";
& }
& public User(int a, string b)
& {
group_no = a;
mail_id = b;
& }

}
class Admin : User
& // this class can't be derive from User and Account, because it's C# :)
{

}


&



class Program
{
& static void Main(string[] args)
& {

& }
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS