Java Program on User Define Wrapper Classes

Free Java courses with 37 real-time projects - Learn Java

Program 1

package dataflair;

public class MyClass 
{
     private byte n;
     public static final int  SIZE=8;
     public static final String  TYPE="byte";
     public static final int MAX_VALUE=127;
     public static final int MIN_VALUE=-128;
    public MyClass() 
    {
    }

    public MyClass(byte n) {
        this.n = n;
    }

    @Override
    public String toString() {
        return " " + n  ;
    }
    
    

}

Program 2

package dataflair;

public class TestMain1 
{
    public static void main(String[] args) 
    {
        // Inbuild class Byte
        System.out.println("Inbuild  byte class");
        System.out.println(Byte.TYPE);
        System.out.println(Byte.SIZE);
        System.out.println(Byte.MAX_VALUE);
        System.out.println(Byte.MIN_VALUE);
        System.out.println("User define Myclass");
        System.out.println(MyClass.TYPE);
        System.out.println(MyClass.SIZE);
        System.out.println(MyClass.MAX_VALUE);
        System.out.println(MyClass.MIN_VALUE);
       
    }
    
}

 

Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *