tostring ( ) method of Java language

to string ( ) method

Syntax:-

            Public string to string ( );

To string is a standard method defined by the Java compiler. Whenever any class contain the body of string ( ) met then Java interpreter access this met during the out put operation of object of class in which it is defined.

Explain throw and throw keyword throw key word :-

Syntax:-

            Throw <object of Exception>;

Throw is a keyword of Java language. It is used to throw the object of type exception form the called for to its respective catch block in which the exception of method is handled.

            Throw key word.

<Return type> <method name> <arguments>throws <exception1, exception2,—- >

{

            —————— }

            ——————}            statements

}

            Throws is a keyword of Java language is used to declare the method for handling exception. Whenever any method is declared by throws keyword then it is necessary for calling statement of that method to handle the exception by using try catch statement.

Leave a Reply

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