Java Program to Convert Octal to Binary

« Previous Program Next Program »

Convert Octal to Binary

To convert octal to binary in Java Programming, you have to ask to the user to enter any number in octal number format to convert it into equivalent binary number format to display the equivalent value in binary number system as shown in the following program.

Java Programming Code to Convert Octal to Binary

Following Java Program ask to the user to enter any Octal Number to convert it into binary, then display the result on the screen:

/* Java Program Example - Convert Octal to Binary */
import java.util.Scanner;

public class JavaProgram
    public static void main(String args[])
        int octnum, rem, quot, i=1, j;
        int binnum[] = new int[100];
        Scanner scan = new Scanner(;
        System.out.print("Enter Octal Number : ");
        octnum = scan.nextInt();
        quot = octnum;
        while(quot != 0)
            binnum[i++] = quot%2;
            quot = quot/2;
        System.out.print("Equivalent Binary Value of " +octnum+ " is :\n");
        for(j=i-1; j>0; j--)

When the above Java Program is compile and executed, it will produce the following output:

Java Program convert octal to binary

Same Program in Other Languages

You may also like to learn and practice the same program in other popular programming languages:

Java Online Test

« Previous Program Next Program »

© Copyright 2021. All Rights Reserved.