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

Practice exercises

Let's try a few exercises that will help us understand and work with arrays. These exercises will also explain concepts while giving an interview.

Print the smallest number in a 3 x 3 matrix

Let's create another class for this exercise, name it InterviewMinnumber, and define the array in the main block. The definition code will be as follows:

int abc[][]={{2,4,5},{3,2,7},{1,2,9}};

This code declares a 3 x 3 matrix named abc. Now we need to traverse each number in the matrix, and look for the smallest number in it. To traverse every number in the multidimensional array, we need to use the same concept that we have used in the Logic programming on multidimensional arrays section.

We use two for loops here: an outer for loop to traverse the rows and an inner for loop to traverse the columns. The two for loops code will look at follows:

for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)

To find the smallest number, we declare a variable, min, and assign the first...