Simple Replace Code:
String str = 'RAM';
System.debug( 'Replace value is ' + str.replace( 'A', 'O' ) );
Output:
Sample Multi-Level or multiple characters replace Code:
String str = 'test';
System.debug( 'Replace value is ' + str.replace( 't', '$' ).replace( 'e', '*' ).replace( 's', '%' ) );
Output: