Answers are added

The code should always be written in a **reusable** and **object oriented** manner. It should not be written to just satisfy one time need. It should be properly designed. Every method should should provide one functionality. Give some time to think about the contract of the method given the functionality it provides.
For example for question1 one approach could be to make a class named `StringUtils` with a method named `removeRepeatedChars`. Then instead of creating a main function and testing anything, one should always write multiple unit tests to test every possible expect.