Q:
C#.Net find output programs (Constructors & Destructors) | set 1
belongs to collection: C#.Net find output programs
C#.Net find output programs
- C#.Net find output programs (Data Types) | set 1
- C#.Net find output programs (Data Types) | set 2
- C#.Net find output programs (Data Types) | set 3
- C#.Net find output programs (Operators) | set 1
- C#.Net find output programs (Operators) | set 2
- C#.Net find output programs (Operators) | set 3
- C#.Net find output programs (const Keyword) | set 1
- C#.Net find output programs (this Keyword) | set 1
- C#.Net find output programs (readonly Keyword) | set 1
- C#.Net find output programs (static Keyword) | set 1
- C#.Net find output programs (static Keyword) | set 2
- C#.Net find output programs (if else) | set 1
- C#.Net find output programs (if else) | set 2
- C#.Net find output programs (if else) | set 3
- C#.Net find output programs (switch statement) | set 1
- C#.Net find output programs (switch statement) | set 2
- C#.Net find output programs (switch statement) | set 3
- C#.Net find output programs (goto) | set 1
- C#.Net find output programs (Loops) | set 1
- C#.Net find output programs (Loops) | set 2
- C#.Net find output programs (Loops) | set 3
- C#.Net find output programs (Arrays) | set 1
- C#.Net find output programs (Arrays) | set 2
- C#.Net find output programs (Arrays) | set 3
- C#.Net find output programs (default Arguments) | set 1
- C#.Net find output programs (default Arguments) | set 2
- C#.Net find output programs (Parameter Passing) | set 1
- C#.Net find output programs (Enumeration) | set 1
- C#.Net find output programs (Enumeration) | set 2
- C#.Net find output programs (Boxing & Unboxing) | set 1
- C#.Net find output programs (Structure) | set 1
- C#.Net find output programs (Structure) | set 2
- C#.Net find output programs (Structure) | set 3
- C#.Net find output programs (Classes & Objects) | set 1
- C#.Net find output programs (Classes & Objects) | set 2
- C#.Net find output programs (Classes & Objects) | set 3
- C#.Net find output programs (Constructors & Destructors) | set 1
- C#.Net find output programs (Constructors & Destructors) | set 2
- C#.Net find output programs (Constructors & Destructors) | set 3
- C#.Net find output programs (Inheritance) | set 1
- C#.Net find output programs (Inheritance) | set 2
- C#.Net find output programs (Inheritance) | set 3
- C#.Net find output programs (Interface) | set 1
- C#.Net find output programs (Interface) | set 2
- C#.Net find output programs (Method Overloading) | set 1
- C#.Net find output programs (Method Overloading) | set 2
- C#.Net find output programs (Method Overriding) | set 1
- C#.Net find output programs (Method Overriding) | set 2
- C#.Net find output programs (Method Overriding) | set 3
- C#.Net find output programs (Operator Overloading) | set 1
- C#.Net find output programs (Operator Overloading) | set 2
- C#.Net find output programs (Operator Overloading) | set 3
- C#.Net find output programs (Namespace) | set 1
- C#.Net find output programs (Namespace) | set 2
- C#.Net find output programs (Exception Handling) | set 1
- C#.Net find output programs (Exception Handling) | set 2
- C#.Net find output programs (Exception Handling) | set 3

c# programming
Answer 1:
Output:
Explanation:
The above program will generate syntax errors because we defined private constructor and Print() method is also private in Employee class, and we know that we cannot access a private member of class outside the class.
Answer 2:
Output:
Explanation:
In the above program, we created a class Sample that contains data member emp_id, name, and salary. Here, we defined a parameterized constructor to initialize the data members, and we also defined a Print() method to print the values of data members.
Now look to the Program class, the Program class contains the Main() method, which is the entry program of the program. Here, we created an object emp of Employee class and initialize members and print employee detail using the Print() method.
Answer 3:
Output:
Explanation:
The above program will generate syntax error, because of the below statement,
In the above statement, we created an object of Employee class using default constructor, but we did not define any default or zero-argument constructor inside the employee class.
Answer 4:
Output:
Explanation:
In the above program, we created a class Sample that contains data member emp_id, name, and salary initialized with 100, "john", and 2000 respectively. Here, we defined a default constructor with an empty body and a parameterized constructor to initialize the data members with specified values, and we also defined a Print() method to print the values of data members.
Now look to the Program class, the Program class contains the Main() method, which is the entry program of the program. Here, we created two objects emp1 and emp2.
Here, object emp1 calls default constructor, but default constructor is defined with the empty body that's why data members of the object contain the pre-initialized values that are printed by the Print() method.
Here, object emp2 calls parameterized constructor, and initialized by specified values and print them using the Print() method on the console screen.
Answer 5:
Output:
Explanation:
The above program will generate syntax errors because of the below code,
public Employee():emp_id(10),name("John"),salary(20000) { }This type of member initialization is not supported in C#. It looks like a member initializer list used in C++.
need an explanation for this answer? contact us directly to get an explanation for this answer