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

1.what are two type of classe members called? 2.what is data hiding and data encapsulation? 3.how do you make a class member visible aouside its class? 4.what is the default visibility of a class data member? 5.what are the advantages of oop over the structured programing?

6 Answers  


#include <iostream> using namespace std; struct wow { int x; }; int main() { wow a; a.x = 22; int c = a.x; int *b = new int; cout << c; return 0; } option: No output 0 22 -(11) Will not compile

1 Answers   CTS, Wipro,


What is overriding vs overloading?

0 Answers  


explain defference between structure and class with example

2 Answers  


What is object-oriented programming? Webopedia definition

0 Answers  


oops concept is used for?

3 Answers   Synergy,


why freind function takes more parameter than normal member function in c++?

1 Answers   IBM,


What is the importance of oop?

0 Answers  


What is command routing in MFC

1 Answers   GE,


what is use to destroy an object? illustrate.

5 Answers   TCS,


Why do we need polymorphism in c#?

0 Answers  


I am DeePu sotware engineer working with EMC corporation ,recently I had attended mcafee interview . Their questions were at heights of stupidity , I don't know what they want , I am a developer with 4 year experienced .I am listing the questions asked 1:What is the flag in g++ to avoid structure padding 2:In wht order parameters are passed to stack 3:How you will edit code segment of an exe

1 Answers  


Categories