Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Study the following class and write a main program for it class Student 4 public int Sto set; get;) public string StName { set:

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

1. Study the following class and write a main program for it class Student 4 public int Sto set; get;) public string StName { set: get; } public Student(int n, string na) 1 StNo=n; StName = na; } public void display) Console.WriteLine("St No: (0) St Name (1)", StNo, StName); > > 2. What is the output of the following program: (composition of classes) public class Person int age: string name; public Person (int a, string n) Age -a; name =n; 1 public int Agel get! return age; } set age=(value>O?value:O); } public string ToStandardString() { return string.Format("Person Name=(0), Age= (1)", name age); 1 1 public class Employee Person info; double salary: public Employee (Person p, double s}{ salarys; info : 3 public string ToStandard String() return string.Format("{0} Salary=(1)", info, salaryl: } 1 public class Employee Test public static void Main() Person p=new Person (30,"Rasha"); Employee em=new Employee(p.10.000); Console.WriteLine (em); Console.ReadLine(); 1 1 3. What is the output of the following program (Overloaded Constructor) public class Students int age; String name, public Students (X age=0; name = "unknown"; Console.WriteLine("Parameter less Constructor"); Console.WriteLine (studentDataToString 0); } public Students (int a, string X age-a; name = n; Console.WriteLine("Constructor with parameters" ); Console.WriteLine (studentDataToString()); public string studentDataToString() { return string.Format("Students Age={O), Name=(1)1", age, name); 1 1 class Students Test public static void Main(string[] args) { Students st1= new Students(); Students st2= new Students (18."Samah"); Console.ReadLine(): Yl/ end Main 1 of 3 Uy the following class and write a main program for it class Student public int StNo { set; get: public string StName set; get;) public Studentfint n, string na) 1 StNo = n; StName = na: 2 public void display) ( Console.WriteLine("St No: (0) St Name (1)", StNo, StName); ) 2. What is the output of the following program: (composition of classes) public class Person int age; string name; public Person (int a, string / Agewa: namen; ) public int Agel get return age; 1 set age=(value>07value:0); ) public string ToStandard Stringl) return string.Format("Person Name={0), Age= {1}", name age); 1 1 public class Employee Person info: double salary: public Employee (Person p, double s) salary info-p: ) public string ToStandardString) 4 return string.Format("{0} Salary=(1)", info, salary): > 1 public class Employee Test public static void Main(X Person penew Personen Rach Employee em=new Employee(p, 10.000)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions