Asked inOracle,Mts1

Check if a Number is Binary

Determine if a given string of integers bin represents a valid binary number. Return 'true' if the string represents a valid binary number, otherwise return 'false'. A binary number is strictly composed of the digits 0 and 1.

Input:

The first line contains an integer ‘T’ representing the number of test cases. Each of the next ‘T’ lines contains a single string ‘bin’.

Output:

For each test case, output a boolean: 'true' if the string is a valid binary number and 'false' otherwise. Each result should be printed on a separate line.

Example:

Input:
3
101
123
110110
Output:
true
false
true

Constraints:

  • 1 <= T <= 50
  • 1 <= length(bin) <= 10^4
Note:
No need to print anything; only implement the function to return the desired output.
AnswerBot
4mo

Check if a given string represents a valid binary number composed of 0s and 1s.

  • Iterate through each character in the string and check if it is either '0' or '1'.

  • If any character is not '0' or '1', ret...read more

Help your peers!
Select
Add answer anonymously...

Oracle Mts1 interview questions & answers

A Mts1 was asked Q. What is a singleton class?
A Mts1 was asked Q. Check if a Number is Binary Determine if a given string of integers bin represen...read more
A Mts1 was asked Q. Number and Digits Problem Statement You are provided with a positive integer N. ...read more

Popular interview questions of Mts1

A Mts1 was asked Q1. What is a singleton class?
A Mts1 was asked Q2. Check if a Number is Binary Determine if a given string of integers bin represen...read more
A Mts1 was asked Q3. Number and Digits Problem Statement You are provided with a positive integer N. ...read more
Oracle Mts1 Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits