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
$17.99 $25.99
Paperback
$32.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
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 : 9781789539769
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.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
$199.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
$279.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 $ 136.97
Java EE 8 Design Patterns and Best Practices
$48.99
Hands-On Automation Testing with Java for Beginners
$32.99
Java Deep Learning Projects
$54.99
Total $ 136.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

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.