Exercise: Python

Questions for: Inheritance

How can you prevent inheritance from a class in C#.NET ?
A:
Declare the class as shadows.
B:
Declare the class as overloads.
C:
Declare the class as sealed.
D:
Declare the class as suppress.
Answer: C
C#.NET allows sealed attribute to be used as a part of class statement. Classes declared with sealed keyword cannot be used as based class for other classes. Most important reason to do this world be to prevent behavior of a class to be changed in any way.
Which of the following should be used to implement a 'Like a' or a 'Kind of' relationship between two entities?
A:
Polymorphism
B:
Containership
C:
Templates
D:
Encapsulation
Answer: E
No answer description is available. Let's discuss.
Which of the following are reuse mechanisms available in C#.NET?
  1. Inheritance
  2. Encapsulation
  3. Templates
  4. Containership
  5. Polymorphism
A:
1, 4
B:
1, 3
C:
2, 4
D:
3, 5
Answer: A
No answer description is available. Let's discuss.
In an inheritance chain which of the following members of base class are accessible to the derived class members?
  1. static
  2. protected
  3. private
  4. shared
  5. public
A:
1, 3
B:
2, 5
C:
3, 4
D:
4, 5
Answer: B
No answer description is available. Let's discuss.
Which of the following is correct about the C#.NET snippet given below?
namespace ExamAdept
{ 
    class Baseclass
    { 
        public void fun()
        { 
            Console.WriteLine("Hi" + " ");
        } 
        public void fun(int i)
        {
            Console.Write("Hello" + " ");
        } 
    } 
    class Derived: Baseclass
    {
        public void fun()
        {
            Console.Write("Bye" + " ");
        } 
    } 
    class MyProgram
    { 
        static void Main(string[ ] args)
        { 
            Derived d; 
            d = new Derived(); 
            d.fun(); 
            d.fun(77);
        } 
    } 
}
A:
The program gives the output as: Hi Hello Bye
B:
The program gives the output as: Bye Hello
C:
The program gives the output as: Hi Bye Hello
D:
Error in the program
Answer: B
No answer description is available. Let's discuss.
Ad Slot (Above Pagination)
Quiz