Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Hands-On Automation Testing with Java for Beginners
Hands-On Automation Testing with Java for Beginners

Hands-On Automation Testing with Java for Beginners: Build automation testing frameworks from scratch with Java

eBook
€13.98 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Hands-On Automation Testing with Java for Beginners

Understanding Classes, Objects, and Their Usage in Java

In the previous chapter, we covered a short introduction to Java and how to install the editor that we will be typing our code in. We also wrote and executed our first code on the editor.

In this chapter, we will go deeper into some basic concepts, such as strings and variables, and how they are different from each other. We will also see what methods are and how they are put to use with different code. We will discuss why objects are important in our code and how we can implement them.

In this chapter, we will cover the following topics:

  • Difference between strings and variables
  • Using methods
  • Importance of classes and objects in Java

Difference between strings and variables

In Chapter 1, First Programming Steps in Java, we printed a string and the variable. If we look closely, when we print a variable we are not using double quotes, but when we print a string, we are using them. This is because the value is already present in the variable, hence we need not use any double quotes. If we use them, Java considers it to be a string and the output will be printed as the letter a in the following example. If we run this and observe the output, the letter a will be printed as shown in the following screenshot:

Output displaying the value of a as per the code

If we don't use double quotes, Java will check whether there is any variable defined with this letter. If so, it prints the value present in that variable. If there is no variable defined, then it gives an error. If we comment out the variable...

Using methods

Basically, methods are blocks in our Java class. Let's write one block here as an example, and observe where the opened and closed brackets are placed. The following example shows one complete block:

public void getData()
{
static int a=4;
}

In this code, we have named the block of code getData() and void is the return type for this method.

If we are expecting to return a number from the method, and the number is an integer, then we have to write integer in place of void. The same applies with strings; if we are planning to return a string from the getData() method, then we have to declare it as a string. If we are not returning anything, that is, if we are simply writing a few lines of code, then we leave it as void.

Take a look at the following screenshot:

Return type is given as void for getData()

Here, we are not returning anything, so we...

Importance of classes and objects in Java

Objects are instances or references of a class. So we can call the methods and variables present in this class with the help of their objects. We cannot call methods and objects directly, we can only use them with the help of their objects. So first, we need to create objects for the class, and then we can call the method inside the main class.

Let's take a look at the previous example to explain this:

package coreJavaTraining;

public class Firstclass {

public void getData()
{
System.out.println(" I am in method");
}
public static void main(String[] args)
{
System.out.println("hi");
System.out.println("hello world");
}
}

Since the main block is already in the class, why do we need to create an object again for this class and call it?

The answer is that there...

Summary

We started off by discussing the difference between strings and variables, and how they appear in a code. We then saw what methods are and how can they be used to write our code. After that, we discussed the importance of classes and objects, and how they are used to call methods that execute a class. We learned how to allocate memory to an object and call the method of that object while executing the code.Finally, we learned how to access a method that is present in another class using objects.

In the next chapter we will learn more about strings and have a look at the String class.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn to use Java program logic in application testing
  • Understand various test-driven development concepts with Java tools
  • Master Java with lots of programming examples

Description

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.

Who is this book for?

Hands-On Automation Testing with Java for Beginners is for software developers who want to step into the world of software quality assurance and perform automation testing using various testing frameworks. Prior experience of writing tests in Java is assumed.

What you will learn

  • Understand the practical usage of Java conditions and loops
  • Write any Java program logic with strategies, tips, and tricks
  • Leverage advanced topics in Java collections to solve Java-related problems
  • Understand and use objects, classes, methods, and functions in Java
  • Build Java automation frameworks from scratch
  • Obtain knowledge of Java object-oriented programming (OOP) concepts with practical implementations

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 29, 2018
Length: 156 pages
Edition : 1st
Language : English
ISBN-13 : 9781789534603
Category :
Languages :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Sep 29, 2018
Length: 156 pages
Edition : 1st
Language : English
ISBN-13 : 9781789534603
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 103.97
Java EE 8 Design Patterns and Best Practices
€36.99
Hands-On Automation Testing with Java for Beginners
€24.99
Java Deep Learning Projects
€41.99
Total 103.97 Stars icon

Table of Contents

11 Chapters
First Programming Steps in Java Chevron down icon Chevron up icon
Understanding Classes, Objects, and Their Usage in Java Chevron down icon Chevron up icon
Handling Strings and Their Functions in Java Chevron down icon Chevron up icon
Building Blocks for Java Programs – Loops and Conditions Chevron down icon Chevron up icon
Everything You Need to Know About Interfaces and Inheritance Chevron down icon Chevron up icon
Learn Everything about Arrays Chevron down icon Chevron up icon
Understanding Date Class and Constructors in Java 11 Chevron down icon Chevron up icon
Importance of the super and this Keywords and Exceptions in Java Chevron down icon Chevron up icon
Understanding the Collections Framework Chevron down icon Chevron up icon
The Importance of the final Keyword, Packages, and Modifiers Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.3
(3 Ratings)
5 star 33.3%
4 star 0%
3 star 0%
2 star 0%
1 star 66.7%
Phani Dec 03, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
One of the Best book for QA folks to understand Java from scratch
Amazon Verified review Amazon
Jambavantha Nov 30, 2018
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
When I looked inside, I see nothing about "Automation Testing" or "Frameworks". This is a book on basic Java. What is Rahul Shetty trying to say?
Amazon Verified review Amazon
Amazon Customer Oct 11, 2021
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
Not worth for quoted price
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.