February 8, 2015

C# Oops Objective type question part 7

1. Interface is a reference type? Is it true?

(A) Yes
(B) No
(C) None of the above

2. Can we declare interface member as static?

(A) Yes
(B) No
(C) None of the above

3. Can we have constructor and destructor in Interface?

(A) Yes
(B) No
(C) None of the above

4. Can we have fields in Interface?

(A) Yes
(B) No
(C) None of the above

5. Can we have constant member in Interface?

(A) Yes
(B) No
(C) None of the above


February 7, 2015

C# Oops Objective type question part 6

1. Static constructor will be invoked only once for any number of instances of the class. Is it true?

(A) Yes
(B) No
(C) None of the above

2. Can we pass any parameter to Static Constructor?

(A) Yes
(B) No
(C) None of the above

3. Can we use access modifier with static constructor?

(A) Yes
(B) No
(C) None of the above

4. Overriding is also known as Dynamic polymorphism. Is it true?

(A) Yes
(B) No
(C) None of the above

5. Shadowing is implemented through new keyword in derived class. Is it true?

(A) Yes
(B) No
(C) None of the above


February 6, 2015

C# Oops Objective type question part 5

1. Public is default access specifier of Namespace? Is it true?

(A) Yes
(B) No
(C) None of the above

2. Internal member will not be accessible in another assembly. Is it true?

(A) Yes
(B) No
(C) None of the above

3. Class cannot be marked as protected or private. Is it true?

(A) Yes
(B) No
(C) None of the above

4. Struct Default member’s accessibility is private. Is it true? 

(A) Yes
(B) No
(C) None of the above

5. Is it true about Protected-Internal;Access is limited to current assembly or types derived from containing class?

(A) Yes
(B) No
(C) None of the above


February 5, 2015

C# Oops Objective type question part 1

1. What is the default access specifier for the class?

(A) Internal
(B) Private
(C) Public
(D) Protected
(E) None of the above

2. What is the default access specifier for the class members?

(A) Internal
(B) Private
(C) Public
(D) Protected
(E) None of the above

3. What is the default access modifier for the Interface members?

(A) Internal
(B) Private
(C) Public
(D) Protected
(E) None of the above

4. What is the default access modifier for the Interface?

(A) Internal
(B) Private
(C) Public
(D) Protected
(E) None of the above

5. What is the default access modifier for enum?

(A) Internal
(B) Private
(C) Public
(D) Protected
(E) None of the above


February 4, 2015

What is copy constructor in Oops?

A parameterized constructor that contains a parameter of itself is called as Copy Constructor. The objective of this  constructor is to initialize the new instance with existing one.

Let’s explain this with an example here:

class A
        {
           
public string Val;

           
public A(string strVal)
            {
                Val = strVal;
            }
           
//This is example of copy constructor.
           
public A(A objA)
            {
                Val = objA.Val;
            }
        }

       
static void Main(string[] args)
        {
           
A objA = new A("Oops");
           
A objAC = new A(objA);//All objA details will be  copied to objAC
           
Console.WriteLine("Value of objAC object == "+ objAC.Val);
           
Console.ReadLine();
        }


Output of this program would be
image 

This example clearly explains what is the role of copy constructor. It can be very handy in certain situation.

February 3, 2015

C# Oops Objective type question part 2

1. Can we instantiate static class?

(A) Yes
(B) No
(C) None of the above

2. Can static class contains non-static members?

(A) Yes
(B) No
(C) None of the above

3. Is Static class sealed?

(A) Yes
(B) No
(C) None of the above

4. Can we declare public constructor  inside static class?

(A) Yes
(B) No
(C) None of the above

5. Is it true? A private constructor prevents the class from being instantiated.

(A) Yes
(B) No
(C) None of the above