Share on Google+Share on Google+

shraddha
ClassCastException
1 Answer(s)      8 years ago
Posted in : Framework

Ads

View Answers

November 11, 2008 at 11:44 PM


Hi friend,

Code to help in solving the problem :

import java.util.*;
class validDate
{
public static void main(String[] args)
{
System.out.println(validDate());
}

public static Boolean validDate()
{

Date date = (Date)getValueToValidate();
System.out.println("date : " + date);
return true;
}

public static Object getValueToValidate() // this method signature cannot change
{
return getDateAsString();
}
public static Date getDateAsString() // this method signature cannot change
{
Date date = new Date();
return date;

}
}

Thanks









Related Tutorials/Questions & Answers:
ClassCastException
ClassCastException  what is the ClassCastException and exp?   ClassCastException occurs, when you try to assign a reference variable...); try { String y = (String)obj; v.add(y); } catch (ClassCastException e
ClassCastException
ClassCastException  what is the ClassCastException and exp?   ClassCastException occurs, when you try to assign a reference variable...); try { String y = (String)obj; v.add(y); } catch (ClassCastException e
Advertisements
ClassCastException
ClassCastException  what is the ClassCastException and exp?   ClassCastException occurs, when you try to assign a reference variable...); try { String y = (String)obj; v.add(y); } catch (ClassCastException e
ClassCastException
ClassCastException  what is the ClassCastException and exp?   ClassCastException occurs, when you try to assign a reference variable...); try { String y = (String)obj; v.add(y); } catch (ClassCastException e
ClassCastException
ClassCastException  what is the ClassCastException and exp?   ClassCastException occurs, when you try to assign a reference variable...); try { String y = (String)obj; v.add(y); } catch (ClassCastException e
ClassCastException
ClassCastException  what is the ClassCastException and exp?   ClassCastException occurs, when you try to assign a reference variable...); try { String y = (String)obj; v.add(y); } catch (ClassCastException e
ClassCastException
the classcastexception occurs. import java.util.*; public class Test1{ public static void main
ClassCastException - Framework
ClassCastException  How to remove the ClassCastException from this validDate()? public Boolean validDate() { // getValueToValidate(); // When I am reading the value, I am getting ClassCastException. Actually I want
ClassCastException - Framework
But this is giving me ClassCastException.  Hi friend, Code to help
why it is throwing classCastException.
why it is throwing classCastException.   public class Redwood extends Tree { public static void main(String[] args) { new Redwood().go(); } void go() { go2(new Tree(), new Redwood()); go2((Redwood) new
java
java  1.Create a class Errorhandle1. Write code that deliberately throws the following exceptions, without using the â??throwâ?? keyword ClassCastException NullPointerException ArrayIndexOutOfBoundsException
exception
exception  1.Create a class Errorhandle1. `Write code that deliberately throws the following exceptions, without using the ??throw?? keyword : ClassCastException NullPointerException ArrayIndexOutOfBoundsException
explanation
explanation  public int compareTo(Object Student) throws ClassCastException { if (!(Student instanceof StudentMarks)) throw new ClassCastException("Not a Student!"); int mark
java fundamental question related to string
??); } } Output? a) the pgm will throw ClassCastException b) compilation
SCJP Module-6 Question-22
Given below the sample code : class main{ try { int a= Integer.parseInt("three"); } } Which exception could be handeled by the catch block for above ? 1.  ClassCastException 2.   
SCJP Module-9 Question-15
will be the output of the above code ? 1. ClassCastException at line 39. 2
Class Cast Exception Example in java
(ClassCastException e) { System.out.println("Class cast exception
Java Comparable Example
){ if(!(ob instanceof Person)){ throw new ClassCastException("Invalid object
Java2Html
Eclipse Plugin Bugfix: conversion caused ClassCastException on some text editors
Java - Java Beginners
ClassCastException { if (!(ob instanceof Employee)) throw new ClassCastException("Error"); int sal = ((Employee) ob).getSalary(); return
need program - Java Beginners
ClassCastException { if (!(Student instanceof ShowData)) throw new ClassCastException("Error"); int studentmarks = ((ShowData) Student).getMarks
writing program - Java Beginners
Player) throws ClassCastException { if (!(Player instanceof ShowData)) throw new ClassCastException("Error"); int averageRuns = ((ShowData
Java - Java Beginners
) throws ClassCastException { if (!(Student instanceof ShowData)) throw new ClassCastException("Error
JAVA - Java Beginners
int compareTo(Object Student) throws ClassCastException { if (!(Student instanceof ShowData)) throw new ClassCastException("Error"); int ide
java error - Java Beginners
Student) throws ClassCastException { if (!(Student instanceof ShowData)) throw new ClassCastException("Error"); int ide = ((ShowData) Student).getId(); return
DNA sequence - Java Beginners
ClassCastException { if (!(Student instanceof ShowData)) throw new ClassCastException("Error"); int ide = ((ShowData) Student).getId(); return this.id - ide
java - Java Beginners
compareTo(Object Student) throws ClassCastException { if (!(Student instanceof ShowData)) throw new ClassCastException("Error"); int ide = ((ShowData
Alphabetical order - Java Beginners
; } public int compareTo(Object Student) throws ClassCastException { if (!(Student instanceof ShowData)) throw new ClassCastException("Error
java - Java Beginners
; } public int compareTo(Object Student) throws ClassCastException { if (!(Student instanceof ShowData)) throw new ClassCastException("Error"); int ide
Sort file data and write into another file
ClassCastException { if (!(Student instanceof ShowData)) throw new ClassCastException("Error"); int ide = ((ShowData) Student).getId(); return
Display Sorted data in TextArea
int compareTo(Object Student) throws ClassCastException { if (!(Student instanceof ShowData)) throw new ClassCastException("Error"); int ide
Tutorials   
Java Spring Hibernate Struts Training Spring 3 MVC Login Form Example Spring 3 MVC Login Form Example Error with LogIn with mysql database Selenium webdriver - Getting Xpath for element in IE Selenium webdriver - Getting Xpath for element in IE springframework Industrial problem maths Groovy Editor using Eclipse RCP Plugin Development Selenium-HP-Alm framework containment how to implement Single Sign On in enterprise application using spring framework Deploy war file Hadoop Mapreduce Java spring 15/03/14 How to found which class or method contain specific annotation? com.pixelmed.dicom.DicomException: No reader for jpeg-lossless available What is Software development framework? pie chart Struts 2 is it necessary to have depth knowledge on servlets jsp and jdbc to learn java frameworks Spring MVC and Hibernate with DWR 3 -- Configuration Using MySQL Database Spring Validations project web programming web programming is it possible to display page in full frame...after dividing page into frames...and is it possible to close frame write code in c# in an application one task has to done for every 15 minutes ? How con you do it? What is the structure of Spring framework? Scheduler triggering cron jobs multiple times at the scheduled time and job is retained even after deleting How to align the select tags in a single column. struts 1.3 array matrix i got illegal start of expression error , plese tell me the mistake where i did... zend2 frame work Spring Login Page Error not able to deploy application war on JBOSS 6.0 running on linux 5.5 URL Regular Expression for Struts Validator URL Regular Expression for Struts Validator getOutputStream() has already been called for this response how to develope a struts application using hibernate? Dialling from computer with other phone via modem card ORACLE- ATG -E Commerce ORACLE- ATG -E Commerce struts need of frameworks in java? need of frameworks in java? need of frameworks in java?

Ads

 
Advertisement null

Ads