RE: Meaning - Abstract classes, abstract methods...
hi
the abstract class is nothing but the class which is having the method that too without body and begin with abstract keyword.a class which is incomplete is termd as abatract class
RE: Meaning - Abstract classes, abstract methods...
Abstract Class:- it has abstract methods and non-abstract methods. Abstract Methods:- this methods has no body. these final and variables of these methods are static final and protected.
In java a class has a well defined structure and behaviour. There are times where we do not need to implement a method such methods are written in the class where the class is preceded by keyword 'abstract' in short we could say that the implementation of the method can be written in the child class of the abstract class to summarize in short an abstract class is a class which contains abstract as well as concrete methods (non abstract which has well defined shape and structure) since because of this we cannot create an object of the abstract class hence memory is not allocated from it but any how we can create a reference for the same.
Eg abstract class ABC {
void add() {// method body .. method is non abstract . }
void sub();//abstract method
}
class XYZ extends ABC { void sub() { SOP('Sub'); }
PSVM(String ar[]) { ABC a ; //we can create reference of an abstract class. XYZ z new XYZ(); // creating object of the child class.
a z; //upcasting . a.sub();// this is possible as we performed upcasting..
} }
but do remember that if you are not implementing the abstract method of the parent class in child class then the child class should be made abstract as well.
Abstract Class: There are two ways to create abstract class one is by mentioning abstract key before the class declaration and second one is by mentioning abstract key before the method declaration we can make that class as abstract class. eg:public abstract class AbstractDem
Abstract method:mention abstract key before declaring the method then it will be a abstract method. eg: public abstract xyz();
implemented example:
package abs;
public abstract class AbstractDem {
/** * @param args */ public abstract void xyz(); public static void xyz1(){System.out.println("method xyz1");}; public static void main(String[] args) { // TODO Auto-generated method stub AbstractDem.xyz1();