#123 Converting Numbers to Foo and Bar

Companies:
Unidata
Themes:
JavaJava BasicsStreams & LambdasPractice

Given a List<Integer>, write a method that returns a List<String> according to the following rules:

  • if a number is divisible by both 3 and 5, return FooBar;
  • if a number is divisible only by 3, return Foo;
  • if a number is divisible only by 5, return Bar;
  • otherwise, return the number itself as a string.

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in