โ† TCS questions

Java Programming Tasks

Filed under TCS

Free read 2 of 3

Understand the exact requirements for file writing (e.g., append vs overwrite) and string manipulation helper methods.

The question

Write Java methods to reverse a given string, check if string b exists as a substring in string a, and write text content to a file.

Constraints

  • Input strings may contain alphanumeric and special characters.
  • File writing should handle standard IO exceptions securely.

Examples

Input
a = "helloworld", b = "world"
Output
Reversed: "dlrowolleh", Substring exists: true
Why
The substring 'world' is found starting at index 5 in 'helloworld'.

Approach

  1. Understand the exact requirements for file writing (e.g., append vs overwrite) and string manipulation helper methods.

Tips

  • What they are testing: Test with empty strings, special characters, and non-existent file paths to ensure robust exception handling.
  • Common mistake: Not properly closing file streams or ignoring IOException propagation during file operations.

Related TCS questions

Collected from public candidate posts and coding forums. Updated Nov 2026.