answersLogoWhite

Top Answer
User Avatar
Wiki User
Answered 2012-04-27 10:13:51

You can't put an abstract method (pure-virtual method) in a normal class because the normal class would become abstract itself. Only non-abstract classes can be physically instantiated as objects, and only if they fully implement all the abstract methods inherited from their base classes.

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

Your Answer

Related Questions


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.


//We Declare an abstract class as-abstract class Car{}//Example of an abstract methodabstract void hondaCity(); //no method body and abstract//Example of Abstract class that has an abstract methodabstract class Car{abstract void run();}class HondaCity extends Car{void run(){System.out.println("runs smartly");}public static void main(String args[]){Car obj = new HondaCity();obj.run();}}//OUTPUT will be-runs smartly


a abstract class is class which has a abstract method which means a method does not its own body.


abstract is keyword this is used for define abstract methods and abstract classes.abstract method means if you want define a method with out any body at that time you should define a method with abstract keyword. EX:public abstract int add() { } if you want define a class with abstract method must and should you define a class will be abstract class. Abstract EX:abstract class abc { abstract methods ------------ non abstract methods ---------------- } you can define abstract as well as non abstract methods in abstract class. in normal class you can define only normal methods only. you can't acess the methods which are in the abstract class from the same clss.by child class only you can acess the methods which are in abstract class. if you want to inherit abstract class must and should you have to define abstract methods which are in abstract class. Interface ----------:- interface is also like a clss.in interface you have to define only abstract methods only.you can't define normal methods in interface. EX: interface abc { abstract methods } by inharitance only you can acess the methods what are in the interface through the class.


An Abstract method is one that has only a method declaration and no method definition. Similarly an abstract class is one that has one or more abstract methods. You can declare an abstract class or methods by using the keyword abstract in the class definition. Ex: public abstract class TestAbsClass { abstract void method1(); } Any class that extends this abstract class must provide implementation to the method "method1" or else it would have to be abstract as well.


public abstract class class_namne{ public abstract void method() {} }


An abstract method is one that is declared, but not implemented. That is, you have an empty method, without the details (the commands in the method). It is meant to be completed in a derived class.


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


Normal variables or static variables are declared and use in class but abstract class had only static variables. You have declare and define the methods in class. But abstract class only allow for method declaration only. The abstract class like interface.


An abstract factory class is a class which has an abstract method to create an object.


when overriding of a class or a method is necessary, they can be declared as abstract


yes,abstract class can have non abstract methods,even it can have all non abstract method


Abstract is the data type which can be used at method and class level... The abstract keyword which we used at method level makes that method as abstract means not giving implementation for that method.. the abstract keyword which used at the class level , restrict developers not to create the object of that class.


An abstract method is a method, in object-oriented software, of an abstract class which has to be implemented by all subtyping classes.


There is no difference with method declaration and implementation between abstract and non-abstract classes. You do the exact same thing when writing a concrete method in either an abstract or non-abstract class.


An overridden method is one which has already been implemented in the parent class with the same signature but has again been coded in the current class for functionality requirements. An abstract method is one which has only been declared in a class and would have to be implemented by the class that extends this abstract class. The implementation for the method is not available in the class in which it is declared.


The same way you create a concrete method in a concrete class. When a class is abstract, it can contain abstract methods. That doesn't mean that all methods must be abstract. Hope this helps.


abstract class in java is mainly designed for giving abstract method i.e declarations alone, Instantiation is a process by which jvm allocates memory for that. But only with the method declaration jvm will not know how much memory should give for the abstract method. So abstract classes are no need to instantiate before the method implementation, The concrete class which extends the abstract class, will provide method implementation at that time only abstract class constructor will run


An abstract class may contain code in method bodies, which is not allowed in an interface. With abstract classes, you have to inherit your class from it and Java does not allow multiple inheritance. On the other hand, you can implement multiple interfaces in your class. Source: Refer Related Links


An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon), like this: abstract void add(double X, double Y);If a class includes abstract methods, the class itself must be declared abstract


If a class has one abstract method ,the class has to be an abstract class.Methods can be implemented in abstract class.Whereas a interface is like a abstract class...the only difference being that the methods are never implemented in Interface.


An abstract method is one that only has a declaration but no definition. An abstract method is usually part of an abstract class. You would typically want to define an abstract class when you want to create an outline of what you want your child classes to do/implement. But, at the same time want to ensure that certain functionality of all your child classes is defined by you. An Abstract class can have both method definitions as well as implementations. So, both of the above can be done in an abstract class. Whereas, an Interface can only have method declarations with no definitions.


Abstract classes are to be extended until to a concrete class.Can have both abstract & non abstract methods.An Abstract class can not be instantiated.A non abstract class can be extended to an abstract class.If At least one abstract method present in a class then that class must be abstract.abstract & final modifiers can never be together.abstract classes can have both abstract methods & non abstract methods.


create shape as an abstract class.............. consider triangle,rectangle,square,.. are the shapes and derive these classes from abstract class................each shapes can have an area for its own... so create area as an abstract method and define this method in each derived class with appropriate formula.........


Abstract MethodsAn abstract method is a method that's been declared as abstract but not implemented. In other words, the method contains no code. You mark a method abstract when you want to force subclasses to provide the implementation.Ex: public abstract void showSample();Notice that the abstract method ends with a semicolon instead of curly braces. It is illegal to have even a single abstract method in a class that is not explicitly declared abstract! Look at the following illegal class:public class IllegalAbstractClass{public abstract void test();}The preceding class will produce the following error if you try to compile it:IllegalClass.java:1: class IllegalAbstractClass must be declaredabstract.It does not define void test() from class IllegalAbstractClass.public class IllegalAbstractClass {1 errorYou can, however, have an abstract class with no abstract methods. The following example will compile fine:public abstract class LegalAbstractClass{void test() {// you can write lots of code here}}In the preceding example, test() is not abstract. Three different clues tell you it's not an abstract method:• The method is not marked abstract.• The method declaration includes curly braces, as opposed to ending in a semicolon. In other words, the method has a method body.• The method contains actual implementation code.Any class that extends an abstract class must implement all abstract methods of the superclass, unless the subclass is also abstract. The rule is this:The first concrete subclass of an abstract class must implement all abstract methods of the superclass.Concrete just means nonabstract, so if you have an abstract class extending another abstract class, the abstract subclass doesn't need to provide implementations for the inherited abstract methods. Sooner or later, though, somebody's going to make a nonabstract subclass (in other words, a class that can be instantiated), and that subclass will have to implement all the abstract methods from up the inheritance tree.



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.