0

Yesterday, I had an interviewing with a company. They ask me "Why do we need an empty class in Java?" I never use an empty class so I have no idea about the purpose of this. Anyone help?

Thank you so much.

FinalDest
  • 49
  • 2
  • 7
  • 4
    Are you sure the question was about an empty **class** and not an empty **interface**? – Mureinik Oct 03 '17 at 08:11
  • Yes. I really sure they asked me about "empty class". I was so confused! – FinalDest Oct 03 '17 at 08:13
  • Maybe the question was about a certain development technique called Test First, also known as TDD (test driven development). It works like first creating a test and running it without having any class to be tested. Then you create the empty class and run the test again. Then you realize, the method you want to test is not in the class, so you create it (with no return value or a dummy). This "game" goes on and on until you have a complete class AND a complete test that covers 100% of the possible tests… But that is just a guess! – deHaar Oct 06 '17 at 12:43

1 Answers1

0

No, we don't need an empty class in Java. We can create one but there is literally no benefit of having that empty class.

Niraj Niroula
  • 2,376
  • 1
  • 17
  • 36