Java BigInteger testBit() MethodLast Updated : 17 Mar 2025 The testBit() method of Java BigInteger class is used to check whether the designated bit is set or not. This method returns true if and only if the designated bit is set. This method computes (this & (1<<n)) != 0). Syntax:Parameter:n- index of the bit to test Returns:The method returns true if and only if the designated bit is set else it will return false. Exception:This method throws an ArithmeticException when n is negative. Example 1Output: Test Bit on 5 at index 2 returns true Test Bit on 5 at index 3 returns false Example 2Output: java.lang.ArithmeticException: Negative bit address Next TopicJava BigInteger |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India