answersLogoWhite

Top Answer
User Avatar
Wiki User
Answered 2012-07-14 12:42:36

An abstract base class may have member variables. Whether or not it actually needs member variables depends on the nature of the base class itself. If the variable is common to all derived classes, then it makes sense to place the variable in the base class. If some derived classes have no need of the variable, then it is better to derive an intermediate class with the variable, and to derive those classes that require that variable from the intermediate class, rather than directly from the abstract class.

001
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0
User Avatar

Your Answer

Related Questions


An abstract class cannot have a constructor and hence you cannot invoke the constructor of the class - i.e., you can instantiate an abstract class and hence you cannot call the constructor of an abstract class.


An abstract class(or classes) can't have a constructor and hence you cannot invoke the constructor of the class (for example, you can instantiate an abstract class and hence you cannot call the constructor of an abstract class).


whatever we write inside a class i.e variable or function is called member of a class.if the member is a variable it is called member variable and if it is a function then it is called a member function. .................Rajesh kumar Mahato


A final class cannot have any subclasses. An abstract class cannot be instantiated unless it is extended by a subclass.


The classes which have one or more abstract methods are abstract. To declare a class as abstract, use the abstract keyword in front of the class keyword, before the class declaration. Abstract classes cannot be instantiated. Similarly the new keyword cannot be used to create an object of the abstract class. Remember that the constructors and static variables cannot be declared as abstract. Any subclass of an abstract class must either implement all of the abstract methods in the superclass or be itself declared abstract.


None. Because an abstract class cannot be instantiated.


Yes. An Abstract class cannot be instantiated.


Any class which has one or more abstract methods is called an abstract class. But in the normal class we can't have any abstract methods. We cannot create an object for the abstract classes. When we inherit the abstract class we should implement the abstract method which we inherit.


A static member variable cannot be initialised inside a class declaration, it must be defined outside the class. It makes no difference if the member is constant or variable. Typically, statics are initialised in the class cpp file while the class is declared in the corresponding header.// file: foo.hclass foo{static const int x;};// file: foo.cpp#include "foo.h"// initialise static member:const int foo::x = 42;


You cannot create an instance of an abstract class. For ex: Public abstract AbsTest { … } AbsTest ex = new AbsTest(); Lets say we have a class declaration AbsTest that is abstract and then I try to instantiate it, the compiler will give me an error stating that "An Abstract class cannot be instantiated"


You cannot. Abstract classes cannot be instantiated and hence cannot be invoked from the main method or any other class directly.


Actually there is no need & most importantly - you cannot create an abstract class without using the abstract keyword


A static member variable is local to the class rather than to an object of the class.


Because, the Abstract class is not a complete class and does not have implementation for a few methods. As a result you cannot instantiate them


Yes, you can declare a final method in an abstract class. However, that method cannot be abstract itself.


Assume a "simple" class be a class without the keyword "abstract".You cannot create an instance of an abstract class. An abstract class is intended to be inherited from (to be extended or derived from).A "simple" class is a class that an instance can be created from (via new operator)


A class member is simply the definition of a member, whether that member is a member variable or a member method. An instance member is the realisation of that definition, just as an object is an instance of a class.


Abstract class is built to promote inheritance whereas a final class is built to avoid inheritanceAn Abstract class can be extended by another class whereas a final class cannot be extended


No. An abstract class is an incomplete class. It does not have all functionality and features implemented in it. So, you cannot instantiate it. If you try to call the constructor for an abstract class, you will get a compilation error


Static member variables of a class are variables that are local to the class within which they are declared. That is, each instance of the class (each object) shares the same common member variable. Changing that variable's value in one instance will change it for all instances. Contrast with a non-static member variable where each instance of the class has its own independent variable, scoped to the object itself (not the class of object).


An abstract class is a class that cannot be directly instantiated. The purpose of such a class is to put some logic in a base class and force derived classes to implement the remaining functionality. Since the full functionality is only available in the derived class, the base class is declared as abstract so that it cannot be instantiated directly.


STATIC DATA MEMBERA data member of a class can be qualified as static. The properties of a static member variable are similar to that of a static variable. A static member variable has certain special characeristics.1) It is initialized to 0(zero) when the first object of this class is created. No other initialization is permitted.2) Only one copy of that member is created for the entire class and is shared by all the objects of that class, No matter how many objects are created.3) It is visible only within the class but its lifetime is in the entire program.The type and scope of each static member variable must be defined outside the class definition.This is necessary because the ststic data member are stored separately rather than as a part of an object. Since they are associated with the class itself rather than with any object. They are also known as class variable.DATA MEMBERData memeber is the simple variable of a class which is initialized by member function of same class. By default data member is private and external functions can not access it.


True - an instance of an abstract class cannot be created. False - derive (subclass) from a class, not the object (the instance).


An Abstract class is a special kind of class that cannot be instantiated. It has one or more methods which are not implemented in the class. These methods are declared abstract and they do not contain any code inside them. Ex: abstract class Parent { public abstract String getSon(); public abstract String getDaughter(); .... .... //More methods that contain specific behaviour/code in them } The above is an abstract class "Parent" that has a lot of functionality but it has declared two abstract methods which have no code inside them. Any class that has one or more abstract methods has to be abstract. This abstract class cannot be instantiated. i.e., the below piece of code will not work. The code will not even compile. Parent object = new Parent();


By using the abstract keyword in the class declaration line. Ex: public abstract ClassName {} The Java compiler will force you to use the abstract keyword in the class declaration line if one or more methods in your class are abstract (no implementation) or if you have not provided implementations for one or more methods of an interface that you are implementing in your class definition. You cannot instantiate an abstract class.



Copyright ยฉ 2021 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.