0 votes
79 views
in Java by
Flexible nature of java.lang.Object

1 Answer

0 votes
by (5k points)
See the following Flexible nature of java.lang.Object:-

java.lang.Object details of objects in following example:-

// Following Program to demonstrate flexible nature of java.lang.Object
public class FlexibleObject
{
    public static void main(String arr[])
    {
        Object obj;
 
        obj = 'D';
        System.out.println(obj.getClass().getName());

    obj = "Hello";
        System.out.println(obj.getClass().getName());
 
        obj = 100;
        System.out.println(obj.getClass().getName());
 
        obj = 100.222;
        System.out.println(obj.getClass().getName());
 
        obj = false;
        System.out.println(obj.getClass().getName());
    }
}

Output:-
java.lang.Character
java.lang.String
java.lang.Integer
java.lang.Double
java.lang.Boolean

Share:- Whatsapp Facebook Facebook


Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.

Categories

...