Abstract Classes and Methods: Abstraction is a process of hiding the implementation details and showing only functionality to
the user.
Another way, it shows only important things to the user and
hides the internal details .
While sending an email we create the body of the mail and subject , and the email address to which we want it to be delivered.
We don't exactly know the internal process of how the e-mail is being delivered to the reciever.
Abstraction lets us focus on what the object does instead
of how it does it.
Abstract Class
A class that is declared using “abstract” keyword is
known as abstract class
It needs to be
extended and its method implemented. It cannot be instantiated.
There are two ways to
achieve abstraction in java
- Abstract
class offers partial (0 to 100%) abstraction
- Interface offer (100%) abstraction
It may or may not include abstract methods which means in
abstract class you can have concrete methods (methods with body) as well along
with abstract methods ( without an implementation, without braces, and followed
by a semicolon).
Example of Abstract
class
// Lines of code below show an abstract class
declaration using keyword “abstract”
abstract class MyAbstractClass{
//line of code below shows an Abstract
method: without body and braces
abstract public void
myAbstractMethod();
// lines of code below show a Concrete
method: with body and braces
public void myConcreteMethod(){
//Write your statements
here
}
}
Note :
while declaration of an abstract class
1.
Declare a class as abstract class if it has both
abstract methods and concrete methods: If the class is having only abstract
methods: declare it as interface.
2.
Declare a class as interface if it has only
abstract methods.
Important points
- Always
declare a class abstract when
there is an abstract method
inside that class .
- An
abstract has to be always extended
by some other class.
- An abstract class may not have
any abstract method .
- An abstract class can have non-abstract methods
(concrete) as well.
- A non-abstract class will have only non-abstract
methods (concrete) .
- A non-abstract can NOT have
an abstract method
- Abstraction
- Method
Overriding
- Method
Overloading
- Instance
Variables
- Java
Applets
- Pop
ups and Alerts
- Absolute path
- Relative path
- Annotations
Selenium Webdriver Browser Commands - Absolute path Vs
Relative path
- Selenium Webdriver Pop
ups and Alerts
- Testng Annotations -
part 1
- Object
Models in QTP - Part 1
Agile Testing Methodology - Extreme Programming
and customer satisfaction
- Mobile testing - What
are the Challenges in mobile testing & Strategies we can follow to
deal with them
- Crowdsource testing -
Crowdtesting
- Model-based testing
(MBT)
- Big Data Testing
- Cloud Testing
- TDD Test Driven
Development
- Verification vs
Validation
- Software Testing
Interview Questions - Mock Test CSTE / ISTQB
- Software testing types
- Risk Management
Comments