Reverse the words in string Answer: import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.print("Enter Original string : ");
String originalStr = s.nextLine();
s.close();
String words[] = originalStr.split("\\s");
String reversedString = "";
//Reverse each word's position
for (int i = 0; i < words.length; i++)
{
if (i == words.length - 1)
reversedString = words[i] + reversedString;
else
reversedString = " " + words[i] + reversedString;
}
// Displaying the string after reverse
System.out.print("Reversed string : " + reversedString);
}
} Output: Enter Original string : Today's Date is 11dec 2023
Reversed string : 2023 dec 12 is Date Today's
public class Main
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.print("Enter Original string : ");
String originalStr = s.nextLine();
s.close();
String words[] = originalStr.split("\\s");
String reversedString = "";
//Reverse each word's position
for (int i = 0; i < words.length; i++)
{
if (i == words.length - 1)
reversedString = words[i] + reversedString;
else
reversedString = " " + words[i] + reversedString;
}
// Displaying the string after reverse
System.out.print("Reversed string : " + reversedString);
}
} Output: Enter Original string : Today's Date is 11dec 2023
Reversed string : 2023 dec 12 is Date Today's
What is Selenium WebDriver
Ans:
Selenium WebDriver is a tool for writing automated tests of websites. It is an API name and aims to mimic the behavior of a real user, and as such interacts with the HTML of the application. Selenium WebDriver is the successor of Selenium Remote Control which has been officially deprecated.
Ans:
Selenium WebDriver is a tool for writing automated tests of websites. It is an API name and aims to mimic the behavior of a real user, and as such interacts with the HTML of the application. Selenium WebDriver is the successor of Selenium Remote Control which has been officially deprecated.
What is Automated Testing?
Ans:
Testing employing software tools which execute tests without manual intervention is called Automated Testing. Can be applied in GUI, performance, API, etc. testing. The use of software to control the execution of tests, the comparison of actual outcomes to predicted outcomes, the setting up of test preconditions, and other test control and test reporting functions.
Ans:
Testing employing software tools which execute tests without manual intervention is called Automated Testing. Can be applied in GUI, performance, API, etc. testing. The use of software to control the execution of tests, the comparison of actual outcomes to predicted outcomes, the setting up of test preconditions, and other test control and test reporting functions.
Can you convert string a =”110a” in integer?
Ans:
No we got NumberFormatException while converting the above string.
Ans:
No we got NumberFormatException while converting the above string.
Which locator you are using in your framework and why?
Ans:
Mostly we used ID and Xpath because Id is the fastest and unique one and after that we prefer Xpath.Anyways we have other locators as well like css , class,name, tag name, Link text,Partial Link text.
Ans:
Mostly we used ID and Xpath because Id is the fastest and unique one and after that we prefer Xpath.Anyways we have other locators as well like css , class,name, tag name, Link text,Partial Link text.
What details are included in the defect report?
Answer- A defect report consists of Defect ID, Description of the defect, Feature Name, Test Case Name, Reproducible defect or not, Status of the defect, Severity, and Priority of the defect, Tester Name, Date of testing of the defect, Build Version in which the defect was found, the Developer to whom the defect has been assigned, name of the person who has fixed the defect, Screenshots of a defect depicting the flow of the steps, Fixing the date of a defect, and the person who has approved the defect.
Answer- A defect report consists of Defect ID, Description of the defect, Feature Name, Test Case Name, Reproducible defect or not, Status of the defect, Severity, and Priority of the defect, Tester Name, Date of testing of the defect, Build Version in which the defect was found, the Developer to whom the defect has been assigned, name of the person who has fixed the defect, Screenshots of a defect depicting the flow of the steps, Fixing the date of a defect, and the person who has approved the defect.
How you can handle the list box?
Answer:Using selenium Select class &it's methods like selectByValue, selectByIndex etc.
Answer:Using selenium Select class &it's methods like selectByValue, selectByIndex etc.
How to capture screen shot in Webdriver?
Ans:
File file= ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(file, new File("c:\\name.png"));
Ans:
File file= ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(file, new File("c:\\name.png"));
Can you tell me about the order of TestNG annotations?
Ans:
@BeforeSuite
@BeforeTest
@BeforeClass
@BeforeMethod
@Test
@AfterMethod
@AfterClass
@AfterTest
@AfterSuite
Ans:
@BeforeSuite
@BeforeTest
@BeforeClass
@BeforeMethod
@Test
@AfterMethod
@AfterClass
@AfterTest
@AfterSuite
Shift-Left Testing: Shift-left testing involves shifting the testing process to the early stages of software development, starting as soon as possible. This helps identify and fix bugs and defects at an early stage, reducing the overall cost and effort required for testing
Shift-Right Testing: Shift-right testing involves testing the software in a production-like environment, using real-world data and scenarios. This helps identify issues and performance bottlenecks that may not be caught during regular testing. Shift-right testing also involves continuous monitoring and feedback, allowing for quick fixes and improvements.
Exploratory Testing: Exploratory testing is a testing approach that emphasizes the tester's creativity, knowledge, and experience. Testers explore the software, its features, and functionalities without any specific test cases or scripts. The goal is to find defects, evaluate usability, and improve the overall quality of the software.
Continuous Testing: Continuous testing is an approach that integrates testing into the software development process at every stage. It involves using automated testing tools and frameworks to continuously test and validate the software as it evolves. Continuous testing helps ensure that the software meets quality standards and is ready for release at any given point in time.
Shift-Up Testing: Shift-up testing involves testing the entire software ecosystem, including the interactions between different software systems and components. This approach focuses on end-to-end testing, ensuring that all systems and components work together seamlessly.
Java code to find Prime Number 1 to 1000
public class PrimeNumber
{
public static void main(String[] args) {
int start = 1;
int end = 1000;
System.out.println("Prime numbers between " + start + " and " + end + " are:");
for (int i = start; i <= end; i++) { if (isPrime(i))
{
System.out.print(i + " ");
}
}
}
// Method to check if a number is prime
public static boolean isPrime(int number)
{ if (number <= 1)
{
return false;
}
// Check for divisibility from 2 to the square root of the number for (int i = 2; i <= Math.sqrt(number); i++)
{ if (number % i == 0)
{
return false; // If divisible, not prime
}
}
return true; // Prime number
}
}
public class PrimeNumber
{
public static void main(String[] args) {
int start = 1;
int end = 1000;
System.out.println("Prime numbers between " + start + " and " + end + " are:");
for (int i = start; i <= end; i++) { if (isPrime(i))
{
System.out.print(i + " ");
}
}
}
// Method to check if a number is prime
public static boolean isPrime(int number)
{ if (number <= 1)
{
return false;
}
// Check for divisibility from 2 to the square root of the number for (int i = 2; i <= Math.sqrt(number); i++)
{ if (number % i == 0)
{
return false; // If divisible, not prime
}
}
return true; // Prime number
}
}
Reverse the words in String (Python)
#function
string
def reverse_words(input_string):
words = input_string.split()
reversed_words = words[::-1]
reversed_string = ' '.join(reversed_words)
return reversed_string
# Main program
if name == "main":
user_input = input("Enter a string: ")
result = reverse_words(user_input)
print("Reversed words string:", result)
#function
string
def reverse_words(input_string):
words = input_string.split()
reversed_words = words[::-1]
reversed_string = ' '.join(reversed_words)
return reversed_string
# Main program
if name == "main":
user_input = input("Enter a string: ")
result = reverse_words(user_input)
print("Reversed words string:", result)
Check Enterted Number Prime or Not(Python)
# Function to check if a number is prime
def is_prime(n):
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True
# Main program
if name == "main":
try:
user_input = int(input("Enter a number: "))
if is_prime(user_input):
print(f"{user_input} is a prime number.")
else:
print(f"{user_input} is not a prime number.")
except ValueError:
print("Please enter a valid integer.")
# Function to check if a number is prime
def is_prime(n):
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True
# Main program
if name == "main":
try:
user_input = int(input("Enter a number: "))
if is_prime(user_input):
print(f"{user_input} is a prime number.")
else:
print(f"{user_input} is not a prime number.")
except ValueError:
print("Please enter a valid integer.")
Java program to arrange the given numbers to form the biggest number
import java.util.*;
public class LargestNumber {
private static class CustomComparator implements Comparator<String> {
@Override
public int compare(String a, String b) {
String order1 = a + b;
String order2 = b + a;
return order2.compareTo(order1);
}
}
public static String formLargestNumber(List<Integer> numbers) {
List<String> strNumbers = new ArrayList<>();
for (Integer number : numbers) {
strNumbers.add(number.toString());
}
Collections.sort(strNumbers, new CustomComparator());
if(strNumbers.get(0).equals("0")) {
return "0";
}
StringBuilder largestNumber = new StringBuilder();
for (String num : strNumbers) {
largestNumber.append(num);
}
return largestNumber.toString();
}
public static void main(String[] args) {
List<Integer> numbers = Arrays.asList(3, 30, 34, 5, 9);
String result = formLargestNumber(numbers);
System.out.println("The largest number formed is: " + result);
}
}
import java.util.*;
public class LargestNumber {
private static class CustomComparator implements Comparator<String> {
@Override
public int compare(String a, String b) {
String order1 = a + b;
String order2 = b + a;
return order2.compareTo(order1);
}
}
public static String formLargestNumber(List<Integer> numbers) {
List<String> strNumbers = new ArrayList<>();
for (Integer number : numbers) {
strNumbers.add(number.toString());
}
Collections.sort(strNumbers, new CustomComparator());
if(strNumbers.get(0).equals("0")) {
return "0";
}
StringBuilder largestNumber = new StringBuilder();
for (String num : strNumbers) {
largestNumber.append(num);
}
return largestNumber.toString();
}
public static void main(String[] args) {
List<Integer> numbers = Arrays.asList(3, 30, 34, 5, 9);
String result = formLargestNumber(numbers);
System.out.println("The largest number formed is: " + result);
}
}