because Object is the base class of all other classes in Java you can assign an instance of any class to a reference of type Object. Therefore you can of course assign the String object ”stringvalue” to it.
But as String is not a subclass of type "B" you obviously can't assign a String to a reference variable of type B.
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad: