Java Interview Questions SET-01
Java Interview Questions Set-02 ARRAY
Java Interview Questions Set-03 MAP
Java Interview Question Set-04
🎃 In test automation with Java, you often need to manipulate and validate strings. Here are eight commonly used Java string methods with examples that are useful for test automation:
🎾 equals() - Compares two strings for content equality.
String expected = "Hello";
String actual = "Hello";
boolean isEqual = expected.equals(actual);
System.out.println("Strings are equal: " + isEqual); // true
🎾 equalsIgnoreCase() - Compares two strings for content equality, ignoring case.
String expected = "Hello";
String actual = "hello";
boolean isEqualIgnoreCase = expected.equalsIgnoreCase(actual);
System.out.println("Strings are equal (ignore case): " + isEqualIgnoreCase); // true
🎾 startsWith() - Checks if a string starts with a specified prefix.
<
String text = "Automation Testing";
boolean startsWith = text.startsWith("Auto");
System.out.println("Starts with 'Auto': " + startsWith); // true >
🎾 endsWith() - Checks if a string ends with a specified suffix.
<
String text = "Automation Testing";
boolean endsWith = text.endsWith("Testing");
System.out.println("Ends with 'Testing': " + endsWith); // true>
🎾 contains() - Checks if a string contains a specified substring.
String text = "This is a sample text.";
boolean containsText = text.contains("sample");
System.out.println("Contains 'sample': " + containsText); // true
🎾 length() - Returns the length of the string.
String text = "Hello, World!";
int length = text.length();
System.out.println("String length: " + length); // 13
🎾 trim() - Removes leading and trailing whitespace from a string.
String text = " Trim me! ";
String trimmedText = text.trim();
System.out.println("Trimmed text: '" + trimmedText + "'"); // "Trim me!"
🎾 split() - Splits a string into an array of substrings based on a delimiter.
String csvData = "John,Doe,30";
String[] parts = csvData.split(",");
System.out.println("First name: " + parts[0]); // "John"
🎾 Substring()
String text = "Hello, World!";
String substring = text.substring(7); // Extracts from index 7 to the end
System.out.println("Substring: '" + substring + "'"); // "World!"
In the above example, substring(7) extracts the substring starting from index 7 (inclusive) to the end of the string. You can also provide two arguments to substring() to specify a starting and ending index.
String substring = text.substring(0, 5); // Extracts from index 0 to 4 (5 is exclusive)
System.out.println("Substring: '" + substring + "'"); // "Hello"
This extracts the substring starting from index 0 (inclusive) to index 4 (exclusive), resulting in "Hello"
🔷 STRING Manipulation Interview Q&A: https://lnkd.in/fFrUPD7
🔷 For SDET or Automation Testing career guidance, mock interviews, job support or framework design, do arrange 1:1 call here : https://lnkd.in/ddayTwnq
*****
Happy testing! 😊🧪 #sidpost and to learn more on API Testing with Postman, Rest Assured, Design Patterns, Architecture, JSON, POJO and many more latest techs with Jenkins & GIT, please refer to the link here: https://docs.google.com/spreadsheets/d/1c0jy99kca_imCmPIQTVuIaPZAHnyIF8qtZhipHi4dLY/edit#gid=1110874939 [Course is crafted by MAANG SDET (LinkedIn Profile), and it also includes pair programming sessions, mock interviews and 1:1 doubt sessions]
📌YouTube channel:
https://lnkd.in/gHJ5BDJZ
📌Telegram group:
https://lnkd.in/gUUQeCha
📌Schedule 1:1 call:
https://lnkd.in/ddayTwnq
📌Medium blogs:
https://lnkd.in/gkUX8eKY
TOP API TESTING INTERVIEW Q&A
*****
For the Top API Testing Interview Q&A, refer the link : https://lnkd.in/drhqciDd
*****
👉 For 1:1 call in Resume & LinkedIn profile help, reach out to me : https://lnkd.in/ddayTwnq
👉 Learn more about API Status codes with examples:
https://lnkd.in/gqCmrjMW
************************************************
************************************************
Learn (API-Microservice)Testing+ Selenium UI Automation-SDET with Self Paced Videos prepared by FAANG employees and LIVE Doubt Session
*******************************************************************For any doubts or career guidance from me, reach out here: https://topmate.io/sidharth_shukla
********************************************************************
****************************************
SDET Interview Question and Answers
TestNG Interview questions and answers
Jenkins Interview Questions and Answers
Appium Interview Questions and Answers
Selenium Interview Questions and answers
Java Coding Interview Questions and Answers
GIT Interview Questions and Answers
************************************************
*************************************************
SeleniumWebdriver Automation Testing Interview Questions:
https://automationreinvented.blogspot.com/search/label/SeleniumWebdriver
API Testing Interview Question Set:
https://automationreinvented.blogspot.com/2022/03/top-80-api-testing-interview-questions.html
DevOps Interview Q&A:
https://automationreinvented.blogspot.com/2021/11/top-11-devops-interview-questions-and.html
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes
Docker Interview Question Set
https://automationreinvented.blogspot.com/Docker
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign
Java Related Interview Question Set
https://automationreinvented.blogspot.com/search/label/Java
GIT Interview Question Set:
https://automationreinvented.blogspot.com/2021/09/top-40-git-interview-questions-and.html
Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions
Mobile Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Mobile%20Testing
Python Interview Question Set for QAE - SDET - SDE:
https://automationreinvented.blogspot.com/search/label/Python
#APITesting #RestAssured #TestingTips #testautomation #software #api #sdet #automation #restassured #career #technology #qualityassurance
No comments:
Post a Comment