Multiple choice general knowledge math & puzzles

In a Java code there are several number of classes & each classes have several methods in it. If the number of classes is decreased by 2 then each class would have 1 method more to keep the total number of methods the same. How many classes are there in that code?

  1. 8

  2. 6

  3. 5

  4. 4

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Let C be classes and M be methods per class. Total = CM. Also Total = (C-2)(M+1). CM = CM + C - 2M - 2 => C - 2M = 2. For C=8, M=3 (Total 24). If C=6, M=4 (Total 24). This fits the condition.