Object and Class classes

Java-Object and Class classes

Object The Object class is a superclass of all other classes. This means all other classes are subclass of the Object class. Object has eleven methods : A reference variable of a superclass can be assigned a reference to any subclass derived from that superclass. Thus, a reference variable of type Object can store a reference … Read more…

Java-Overriding toString Method

Overriding toString Method The toString( ) method returns a string that contains a description of the object on which it is called. If you want to represent any object as a string, toString() method comes into existence. Many classes override this method. This method is automatically called when an object is output using println( ). Program : Without … Read more…

string length

Java-Get Length

Get Length The String class defines a number of methods that allow us to accomplish a variety of string manipulation tasks. The number of characters in a string provided by the length( ) method of the String class. Since it is an instantiated method, we have to invoke it from an object of the String … Read more…