Question
Complete the Java code to replace all occurrences of a specific word (case-insensitive) in a string. public class RegexReplacer { public String replaceWord(String text, String wordToReplace, String replacement) { // Example: text="Hello World", wordToReplace="world", replacement="Java" // Expected: "Hello Java" String regex = "(?i)\\b" + Pattern.quote(wordToReplace) + "\\b"; _________ // Line to complete } }
More IT Operating System Questions
- The OS component responsible for managing memory, processes, devices, and files is called:
- What is the primary benefit of polymorphism?
- Using the Shortest Seek Time First (SSTF) disk scheduling algorithm, the disk head starts at cylinder 53, and the pending request queue is 98, 183, 37, 122...
- Consider a self-join query to find all pairs of employees who have the same manager: SELECT e1.name, e2.name FROM Employees e1, Employees e2 WH...
- What is the primary goal of analyzing an algorithm's space complexity?
- In a graph represented using an adjacency matrix with V vertices, what is the space complexity?
- Consider the following Python code: s = "PythonProgramming" part1 = s[2:6] # Corrected line part2 = s[-5:] print(part1 + part2) What will be the o...
- When page fault rate is extremely high and the CPU spends most of its time on page replacement rather than executing processes, this condition is called?
- When building a Huffman tree, the two nodes with the smallest frequencies are combined. Which line correctly creates a new parent node newNode with left an...
- When page fault rate is extremely high and the CPU spends most of its time on page replacement rather than executing processes, this condition is called?
Hey! Ask a query
Please enter email id
The email must be a valid email address.
Please enter Mobile Number
Please enter valid Mobile Number
Please enter your Doubt
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
- 200 Questions with Detailed Solutions
- Section-wise Coverage (GA, English, Quant & Reasoning)