Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How would you stop a class from class from being derived or
inherited.

Answers were Sorted based on User's Feedback



How would you stop a class from class from being derived or inherited...

Answer / stavan

By Creating class as a private.
It will not allow that class to inherited.

private class A{
// code
}


class B extends A{ // It will not work.
// Code
}

Is This Answer Correct ?    0 Yes 1 No

How would you stop a class from class from being derived or inherited...

Answer / siva

Final Class...

Is This Answer Correct ?    0 Yes 1 No

How would you stop a class from class from being derived or inherited...

Answer / abhijit

class ASealedClass;

class MyFinalClass
{
friend ASealedClass;

private:
MyFinalClass(int dummy) {}
};


class ASealedClass : virtual MyFinalClass
{
public:
ASealedClass() : MyFinalClass(0) {} // this is the key .. it
is the virtual inheritance that prevents inheritance
};

Is This Answer Correct ?    1 Yes 4 No

How would you stop a class from class from being derived or inherited...

Answer / naveen

by making the constructor private....

Is This Answer Correct ?    0 Yes 4 No

How would you stop a class from class from being derived or inherited...

Answer / abhi

I think by making all data msmbers and member functions
protected..
May be this is soln

Is This Answer Correct ?    0 Yes 4 No

How would you stop a class from class from being derived or inherited...

Answer / mohit jethva

make class static then it will not derive

Is This Answer Correct ?    2 Yes 8 No

How would you stop a class from class from being derived or inherited...

Answer / abhijit pritam

Only fifth answer is correct (for C++)

Is This Answer Correct ?    0 Yes 8 No

How would you stop a class from class from being derived or inherited...

Answer / vishaka

The class shoul be made abstract to stop it from being
derived or inherited. To make a class abstract, it should
have atleast one pure virtual function.

Is This Answer Correct ?    2 Yes 21 No

Post New Answer

More OOPS Interview Questions

What are the main differences between procedure oriented languages and object oriented languages?

9 Answers   IBM, Infosys, Wipro,


What language is oop?

0 Answers  


Write a program to demonstrate the use of 'Composition' in C++

2 Answers  


What is class and object in oops?

0 Answers  


What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?

1 Answers  


What is the difference between pass by value,pass by pointer,pass by reference in the catch block in the exception handling in c++

1 Answers   TCS,


suppose A is a base class and B is the derved class. Both have a method foo which is defined as a virtual method in the base class. You have a pointer of classs B and you typecast it to A. Now when you call pointer->foo, which method gets called? The next part of the question is, how does the compiler know which method to call?

3 Answers   EA Electronic Arts,


What is an interface in oop?

0 Answers  


I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...

0 Answers  


Why polymorphism is used in oops?

0 Answers  


WAP to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)

1 Answers  


What is use of overloading?

0 Answers  


Categories