```python
def replace_char(str1,ch,newch):
  """
  Replaces all occurrences of a character in a string with a new character.

  Args:
    str1: The input string.
    ch: The character to be replaced.
    newch: The character to replace with.

  Returns:
    A new string with the specified character replaced.
  """
  return str1.replace(ch, newch)
```