source file name:  Div4or6Demo.java

import java.io.*;

class A

{

int y;

public A(int n)

{

y=n;

}

public void disp()

{

if(y%4==0)

System.out.println("Given number is Divisible by only 4 ");

if(y%6==0)

System.out.println("Given number is Divisible by only  6 ");


if(y%4!=0 && y%6!=0)

System.out.println("Given number is not Divisible by both ");

}

}

class Div4or6Demo

{

public static void main(String as[])

int n=1;

System.out.println("enter value: ");

try

{

DataInputStream dis=new DataInputStream(System.in);

String s=dis.readLine();

n=Integer.parseInt(s);

}

catch(Exception e)

{

System.out.println(e);

}

A ob=new A(n);

ob.disp();

}

}

output:


D:\JavaPrograms\Constructors>java Div4or6Demo
enter value:
40
Given number is Divisible by only 4
Given number is not Divisible by both

D:\JavaPrograms\Constructors>java Div4or6Demo
enter value:
36
Given number is Divisible by only 4
Given number is Divisible by only  6

D:\JavaPrograms\Constructors>java Div4or6Demo
enter value:
42
Given number is Divisible by only  6
Given number is not Divisible by both