Count total set bits
Your way of indenting and placing braces is consistent, which is good.
I prefer the K&amp;R style, which
is also recommended in the (historical) Java Code Conventions from
Sun Microsystems, or the Google Style Guides:


  
  Open brace “{” appears at the end of the same line as the declaration statement
  Closing brace “}” starts a line by itself indented to match its corresponding opening statement, ...
  

You have separated the I/O from the actual computation, which is again
good, as it keeps the main method short, and allows to add unit tests
more easily.
Reading the input can be simplified slightly by using Scanner.
Short (nondescriptive) variable names T and N are usually not recommended.
In this case it might be acceptable, since those names correspond directly
to the identifiers used in the programming challenge description.

However, it is not immediately apparent what the method names noOfBits
and numBits stand for, and what distinguished them. A better choice could
be totalSetBits (corresponding to the challenge description), and 
countBits, plus short explaining comments.
I am not sure if the special treatment of powers of 2 in if ((i &amp; i-1) == 0)
is worth the additional code, as it applies only to few numbers in the range
1...N. In any case, it should be part of the numBits() method.
The separate variable int rem in numBits() is not needed.


Summarizing the suggestions so far, the code would look like this:

import java.io.IOException;
import java.util.Scanner;

class GFG {

    // Total count of all 1 bits in the binary representation of the
    // numbers 1 ... N.
    private static int totalSetBits(int N) {
        int sum = 0;
        for (int i = 1; i &lt;= N; i++) {
            sum += countBits(i);
        }
        return sum;
    }

    // Number of 1 bits in the binary representation of n.
    private static int countBits(int n) {
        if ((n &amp; n-1) == 0) {
            return 1; // n is a power of 2.
        }
        int count = 0;
        while (n != 0) {
            count += n % 2;
            n /= 2;
        }
        return count;
    }

    public static void main (String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        int T = scanner.nextInt();
        for (int i = 1; i &lt;= T; i++) {
            int N = scanner.nextInt();
            int bits = totalSetBits(N);
            System.out.println(bits);
        }
    }
}


How can we make this faster? One approach would be
to make countBits() faster, and you'll find various methods to count
the number of set bits in an integer at
Bit Twiddling Hacks.

But perhaps we can compute totalSetBits(N) better than
adding countBits(n) for all numbers n from 1 to N? This is the real
challenge here, and I don't want to deprive you from the satisfaction of
figuring out the solution yourself, so here are some hints only:

First have a look at some special values:


0
1  --> totalSetBits(1) = 1

00
01
10
11 --> totalSetBits(3) = 2 * 2 = 4

000
001
...
110
111 -> totalSetBits(7) = 3 * 4 = 12


Can you spot the general pattern?

Then try compute totalSetBits(N) for arbitrary N by using
those “special values.” This should lead to a \$ O(\log N) \$ solution
instead of the current \$ O( N) \$ solution.

And of course – when not in an interview – you can “cheat:” Compute totalSetBits(N) for the first
(e.g.) 40 values of N, and look up the resulting sequence in the
On-Line Encyclopedia of Integer Sequences®. For many
programming challenges, this leads to useful information and insights into
the problem.