Book Image

Hands-On Automation Testing with Java for Beginners

Book Image

Hands-On Automation Testing with Java for Beginners

Overview of this book

Java is one of the most commonly-used software languages by programmers and developers. Are you from a non-technical background and looking to master Java for your automation needs? Then Hands-On Automation Testing with Java for Beginners is for you. This book provides you with efficient techniques to effectively handle Java-related automation projects. You will learn how to handle strings and their functions in Java. As you make your way through the book, you will get to grips with classes and objects, along with their uses. In the concluding chapters, you will learn about the importance of inheritance and exceptions with practical examples. By the end of this book, you will have gained comprehensive knowledge of Java.
Table of Contents (17 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
Index

Interfaces


The interface is one of the core concepts used in Java OOPS, so it's necessary for us to familiarize ourselves with interfaces and their use.

Interfaces are similar to classes. The only difference between an interface and a class is that an interface will have methods but not a body. Confused? In a class, we generally define a method and then start writing code into it. For example, in a class, if we want to write any code, we just start off by declaring the class using public void and proceed with the rest of the code in that class, as follows:

public void getData()
{
}

In interfaces, we can only define the signature of the method; we cannot write any code inside the method. But why? What is the use of writing a method signature inside an interface? What is the use of this object-oriented concept in Java? You might have these questions in your mind, so let's try to understand the concept of the interface with a real-life scenario.

Using interfaces with a traffic light system

Consider...