how to find common elements in arraylists java

You were given two arraylists as below and you have to identify the common elements present in them. ArrayList1: [sleenium99, automation, tutorials, java] ArrayList2: [arraylist, sleenium99, automation, tutorials, collections] Output is: [sleenium99, automation, tutorials] Method 1: We are going to achieve this task with the help of retainAll method present in the ArrayList.

Output:… Read More »

java question 5

1 What is the output of below code snippet?

Options: A. “123451234512345” B. Prints a negative integer value C. “12345100000” D. Compilation error 2. Given the following definitions, which of these expressions will NOT evaluate to true?

Options: A. b1 | !b2 B. (i1 ^ 12) < 4 C. i2 & b1 D.… Read More »

java files

File class is present in package and we can work with File class to read or write data.

Below are the methods present in File class.   Method Type Description length() String Returns the length of the file. canRead() Boolean Tests whether the file is readable or not. canWrite() Boolean Tests whether the… Read More »

java map examples

Difference between HashMap, LinkedHashMap, TreeMap and Hashtable with examples: HashMap LinkedHashMap TreeMap HashTable Insertion Order No Yes Yes No Null key allowed allowed Not allowed Not allowed Null value allowed allowed allowed Not allowed Examples:


================== Duplicate keys are not allowed in map and each key can map to at most… Read More »


1 Which one of the following represents legal flow control statements? a. break; b. break(); c. continue(inner); d. exit();   2. Predict the output from below java program.

Options: A. Got the exception 10 B. Go the exception 0 C. Compile time error D. Run-time error   3. Output of below java program.

Read More »

advanced sql functions

Advanced SQL functions: COALESE: This function is used to return first non-NULL value from the list or from the table. Examples: SELECT COALESCE(NULL, 1, 2, ‘’); –> Returns 1 SELECT COALESCE(NULL, 500, NULL, 200, ‘’); –> Returns 500 SELECT COALESCE(NULL, 77, ‘automation’, ‘’); –> returns 77 SELECT COALESCE(NULL, NULL, ‘automation’, ‘selenium99’); –> Returns automation SELECT COALESCE (NULL,NULL,NULL,NULL,’selenium99′,700);… Read More »

selenium interview questions basic level

In this article you will find the selenium interview questions of basic level. 1. What is an exception test in Selenium? An exception test is an exception that you expect will be thrown inside a test class. For example, if you have written an automation test script in such way that it should throw an… Read More »

string initialization

In this article, you will find types of string array initialization. 1. what is the use of { } in below statement? String[] array= new String[]{}; Ans: Here it initializes the string array with the values between { }. In this case zero elements, so array.length == 0 and array[0] throws IndexOutOfBoundsException. 2. What is… Read More »

hashset and linkedhashset differences in java

Differences between HashSet and LinkedHashSet in Java:   S.No HashSet LinkedHashSet 1 HashSet doesn’t maintain insertion order. LinkedHashSet maintains insertion order. 2 Unordered. Order is unpredictable when we iterate through the elements. Ordered and gives predictable output. 3 If you don’t want to maintain insertion order and should have unique values then you can use… Read More »

How to take screenshot using Selenium WebDriver

Taking screenshot using selenium is simple and it helps us to debug the failure and to find out the root cause. By looking at screenshot, we can get to know the details why and at which step test has failed. TakesScreenShot interface is used to achieve this task and this TakesScreenShot capability is enabled by… Read More »

How to select a dropdown using selenium web driver

In this article, we are going to learn about how to select a drop down using selenium webdriver. In our selenium automation, we may come across situations like entering text, selecting radio buttons and check boxes etc. Like this way, selenium handles dropdowns in an easy manner. Points to remember: Using selenium web driver, we… Read More »

TestNG annotations

Below is the list of annotations in TestNG. @BeforeTest @AfterTest @BeforeMethod @AfterMethod @BeforeSuite @AfterSuite @BeforeGroups @AfterGroups @BeforeClass @AfterClass @Test @BeforeTest: Executes before any method in a class which is having @Test annotation. @AfterTest: Executes after any method in a class which is having @Test annotation. @BeforeMethod: Executes every time before any test method in a… Read More »

Implicit and Explicit wait in Selenium

During automation script development, its common that at least once in their test execution, their scripts have failed due to WebDriver couldn’t able to find element in the web page. This issue can be resolved by using selenium wait conditions appropriately. Page load speed depends on the how fast the response is coming from web… Read More »

How to handle mouse hover events using Selenium WebDriver

In this article, we will learn about how to handle the mouse hover events using selenium webdriver. Firstly, we have to hover mouse over the menu item. This displays the dropdown list/sub menu items. Next, we have to select the sub elements from the list and have to click on one of the sub element.… Read More »

encapsulation in java

Encapsulation in java: Encapsulation = Data Hiding + Abstraction. It means if any component is following Abstraction as well as data hiding then it is also following Encapsulation. Encapsulation: It is actually the process of binding data members and methods together in a unit. Each class in java itself is an example of encapsulation. It… Read More »

general selenium questions

1. Find element using xpath and cssSelector. Html code: <a class=”shopicon relative”>Shopping</a> Solution:  //a[@class=’shopicon relative’]   –> using xpath in firefox .shopicon.relative   –> using cssSelector in chrome //a[text()=’Shopping’] –> text() method 2. In the “” website, ways to find NEWS link are: Using cssSelector: .navbar>:nth-child(1)>:nth-child(2) .navbarul>:nth-child(2) Using xpath: //a[text()=’NEWS’]   Related articles: Waits in Selenium WebDriver


TestNG is a test automation framework emerged to overcome the limitations of both JUnit and NUnit. It has many new features which are more powerful and easy to use. Annotations. Multithread safe tests. Data driven testing. Parameterization support. TestNG supports a different variety of tests like unit, integration, system, functional and end to end. Setup… Read More »


Introduction: Selenium Tutorials: Selenium is a free and open source test automation tool for testing web applications. Selenium can be installed on most of the operating systems like Windows  Linux  Apple iOS   etc. Cross browser testing is possible using selenium i.e., we can run the test scripts in different browsers like Firefox  IE  Chrome  Opera … Read More »

Selenium Interview Questions

Realtime Selenium Interview Questions: ADP Written test questions: 1. How to find inner text using CSS attribute. Options: css=tag:attribute (“inner text”); etc. 2. How to find words starting with ADP using CSS. Below are the few options. tag:attribute(“starts-with@id, “ADP”); tag:attribute(“@id, “ADP”); etc. 3. A question about Actions element. 4. Context click is used for ?… Read More »

How to handle alerts in Selenium WebDriver

Selenium WebDriver is able to handle alerts in addition to the windows and frames. What is an alert? Alert is a popup or message box which displays on the screen. Alerts can appear on the screen due to various user actions. For example, alert can appear when you click on a button or trying to… Read More »