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

Flexible nature of java.lang.Object

0 votes
18 views
Flexible nature of java.lang.Object
asked Nov 19, 2017 in Java by Nikhil Kumar

1 Answer

0 votes
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
answered Nov 20, 2017 by ranju_12 (1,460 points)
...