1Sometimes we may come across a situation where we cannot provide
2implementation to all the methods in a class. We want to leave the
3implementation to a class that extends it. In such case we declare a class
4as abstract.To make a class abstract we use key word abstract.
5Any class that contains one or more abstract methods is declared as abstract.
6If we don’t declare class as abstract which contains abstract methods we get
7compile time error.
8
9 1)Abstract classes cannot be instantiated
10 2)An abstarct classes contains abstract method, concrete methods or both.
11 3)Any class which extends abstarct class must override all methods of abstract
12 class
13 4)An abstarct class can contain either 0 or more abstract method.
1An abstract method is the method which does’nt have any body.
2Abstract method is declared with
3keyword abstract and semicolon in place of method body.
4
5 public abstract void <method name>();
6Ex : public abstract void getDetails();
7It is the responsibility of subclass to provide implementation to
8abstract method defined in abstract class
1Interface
21) Interface contains only abstract methods
32) Access Specifiers for methods in interface
4must be public
53) Variables defined must be public , static ,
6final
74) Multiple Inheritance in java is implemented
8using interface
95) To implement an interface we use
10implements keyword
11
12Abstract Class
131) Abstract class can contain abstract methods,
14concrete methods or both
152) Except private we can have any access
16specifier for methods in abstract class.
173) Except private variables can have any access
18specifiers
194)We cannot achieve multiple inheritance using
20abstract class.
215)To implement an interface we use implements
22keyword
1Interfaces specify what a class must do and not how.
2It is the blueprint of the class.
3It is used to achieve total abstraction.
4
5We are using implements keyword for interface.
6
7Abstract=
8Sometimes we may come across a situation
9where we cannot provide implementation to
10all the methods in a class. We want to leave the
11implementation to a class that extends it.
12 In that case we declare a class
13as abstract by using abstract keyword on method
14signature.In my framework I have created my
15PageBase class as super
16class of the all page classes.
17I have collected all common elements
18and functions into PageBase class and
19all other page classes extent PageBase class.
20By doing so, I don't have to locate very
21common WebElements and it provides
22reusability in my framework.
23Also
241)Abstract classes cannot be instantiated
252)An abstarct classes contains abstract method,
26concrete methods or both.
273)Any class which extends abstarct class must
28 override all methods of abstract class
294)An abstarct class can contain either
30 0 or more abstract method.
31
1abstract class have no implementation of methods functions inside it. the classes which extending abstract class have to implement it
2