Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Prepare for your Java exam with our ultimate quiz based on 'Thinking in Java'. Engage with expertly crafted questions that enhance your learning process. Perfect for Java enthusiasts looking to solidify their knowledge!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


Which method checks the number of bytes that can be read without blocking?

  1. read

  2. available

  3. checkRead

  4. peek

The correct answer is: available

The method that checks the number of bytes that can be read without blocking is the 'available' method. This method returns an integer representing the number of bytes that can be read without blocking and therefore allows for the reading of data without interruption. Options A, C, and D are incorrect as they do not provide a function to determine the number of bytes that can be read without blocking. Option A, 'read', simply reads the data and does not provide any information about how much data can be read. Option C, 'checkRead', is not a valid method for checking the number of bytes and option D, 'peek', only allows the user to see the next byte without actually reading it. Therefore, 'available' is the only valid option for checking the number of bytes that can be read without blocking.