Inheritance c programming questions

11.

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
E.     Inheritance
Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
12.

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.
E.     Declare the class as override.
Answer & Explanation

Answer: Option C

Explanation:

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.
View Answer Workspace Report Discuss in Forum
13.

Which of the following statements are correct about Inheritance in C#.NET?

A derived class object contains all the base class data.
Inheritance cannot suppress the base class functionality.
A derived class may not be able to access all the base class data.
Inheritance cannot extend the base class functionality.
In inheritance chain construction of object happens from base towards derived.

A.     1, 2, 4
B.     2, 4, 5
C.     1, 3, 5
D.     2, 4
Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
14.

Assume class B is inherited from class A. Which of the following statements is correct about construction of an object of class B?
A.     While creating the object firstly the constructor of class B will be called followed by constructor of class A.
B.     While creating the object firstly the constructor of class A will be called followed by constructor of class B.
C.     The constructor of only class B will be called.
D.     The constructor of only class A will be called.
E.     The order of calling constructors depends upon whether constructors in class A and class B are private or public.
Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
15.

Which of the following statements is correct about the C#.NET program given below?

namespace IndiabixConsoleApplication
{
class Baseclass
{
int i;
public Baseclass(int ii)
{
i = ii;
Console.Write(“Base “);
}
}
class Derived : Baseclass
{
public Derived(int ii) : base(ii)
{
Console.Write(“Derived “);
}
}
class MyProgram
{
static void Main(string[ ] args)
{
Derived d = new Derived(10);
}
}
}

A.     The program will work correctly only if we implement zero-argument constructors in Baseclass as well as Derived class.
B.     The program will output: Derived Base
C.     The program will report an error in the statement base(ii).
D.     The program will work correctly if we replace base(ii) with base.Baseclass(ii).
E.     The program will output: Base Derived
Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question.

Leave a Reply0

Your email address will not be published.