SCJP Certification

Sun Certified Java Programmer Certification exam essentials

November 3rd, 2009

What is the ClassCastException?

Java Facts, by Daisy Williams.

A ClassCastException is thrown when an attempt is made to cast an object, which is not of the appropriate run-time type. It extends from the RuntimeException class. It For example:

Object obj = new Vector();
String s = (String) obj;

Following are the two kinds of constructors for ClassCastException:

ClassCastException()

It will construct a ClassCastException without any detailed message.

ClassCastException(String str)

It will construct a ClassCastException with the specified detailed message.

Share

Back Top

Responses to “What is the ClassCastException?”

Comments (0) Trackbacks (0) Leave a comment Trackback url
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

*