Premium Employer

HCLTech

3.6
based on 33.6k Reviews
Filter interviews by

10+ Interview Questions and Answers

Updated 8 Oct 2024
Popular Designations

Q1. what is the output of below code class Animal{ Animal(){ System.out.println("animal is created") } class Dog extends Animal{ Dog(){ System.out.println("Dog is created")} class TestSuper4{ public static void mai...

read more
Ans.

The output of the code will be 'animal is created' followed by 'Dog is created'.

  • The code defines a class Animal with a constructor that prints 'animal is created'.

  • It also defines a class Dog that extends Animal, with a constructor that prints 'Dog is created'.

  • In the main method, an instance of Dog is created, which will trigger the constructors of both Animal and Dog classes.

Add your answer

Q2. Which is valid or invalid a. ChromeDriver driver=new ChromeDriver(); b. WebDriver driver=new ChromeDriver(); c. WebDriver driver2=new WebDriver(); driver2=new ChromeDriver();

Ans.

Option a is valid, option b is valid, option c is invalid.

  • Option a is valid because ChromeDriver is a subclass of WebDriver, so it can be assigned to a WebDriver reference.

  • Option b is valid because ChromeDriver is a subclass of WebDriver, so it can be instantiated using a WebDriver reference.

  • Option c is invalid because WebDriver is an interface and cannot be instantiated directly. It can only be used as a reference type.

Add your answer

Q3. difference between getwindowhandle and getwindowhandles() and what is output type

Ans.

getwindowhandle returns the handle of the current window, getwindowhandles() returns handles of all open windows

  • getwindowhandle returns a single window handle, while getwindowhandles() returns a set of window handles

  • getwindowhandle is used to switch between windows in Selenium WebDriver

  • Output type of getwindowhandle is String, while output type of getwindowhandles() is Set

Add your answer

Q4. Find the combained charected in the given testing exmple : " Testing Testing Testing" , cobained text is "te"

Ans.

The combined characters in the given testing example 'Testing Testing Testing' is 'te'.

  • Iterate through the text and check for consecutive characters 'te'.

  • Combine the characters 'te' whenever they are found together.

  • Return the combined text 'te' as the result.

Add your answer
Discover null interview dos and don'ts from real experiences

Q5. Program to sort the input in descending order without using inbuild method/functions

Ans.

Sort input array of strings in descending order without using inbuilt functions

  • Iterate through the array and compare each element with the rest to find the largest element

  • Swap the largest element with the first element, then repeat the process for the remaining elements

  • Continue this process until the array is sorted in descending order

Add your answer

Q6. Output of this : String name="Hello"; name=name+"There"; system.out.println(name)

Ans.

The output will be 'HelloThere'

  • Concatenation of 'Hello' and 'There' results in 'HelloThere'

  • The final string is printed using System.out.println()

Add your answer

Q7. StringBuffer buffer=new StringBuffer("Hello") buffer.append("There"); System.out.println(buffer);

Ans.

The code creates a StringBuffer object with 'Hello' and appends 'There' to it before printing the final string.

  • StringBuffer is mutable, so the original 'Hello' string can be modified

  • The append() method adds the specified string to the end of the buffer

  • The final output will be 'HelloThere'

Add your answer

Q8. Difference between String and StringBuilder?

Ans.

String is immutable, while StringBuilder is mutable and more efficient for concatenating strings.

  • String is immutable, meaning its value cannot be changed once it is created.

  • StringBuilder is mutable, allowing for modifications to the string without creating a new object.

  • StringBuilder is more efficient for concatenating multiple strings as it does not create new objects each time.

  • Example: String str = "Hello"; StringBuilder sb = new StringBuilder("Hello");

Add your answer

Q9. difference between findElement and findElements

Ans.

findElement returns the first matching element on the page, while findElements returns a list of all matching elements.

  • findElement returns a single WebElement matching the locator provided

  • findElements returns a list of WebElements matching the locator provided

  • findElement will throw NoSuchElementException if no element is found, while findElements will return an empty list

Add your answer

Q10. Find the 2nd largest number in the given array

Ans.

Find the 2nd largest number in the given array

  • Sort the array in descending order

  • Get the element at index 1, which will be the 2nd largest number

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at null

based on 3 interviews in the last 1 year
1 Interview rounds
Technical Round
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Automation Engineer Interview Questions from Similar Companies

3.8
 • 17 Interview Questions
3.8
 • 11 Interview Questions
3.8
 • 10 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter