class Parent { int data; } class Child extends Parent { String name; } class Uncle { String rich; } class Casting { public static void main( String args[] ) { Object object; Parent parent; Child child = new Child(); Uncle uncle; parent = child; object = child; parent = (Parent) object; child = (Child) object; uncle = (Uncle) object; //Runtime exception }}
class Compare { public static void main( String args[] ) { float nan = Float.NaN; float positiveInfinity = Float.POSITIVE_INFINITY; float negativeInfinity = Float.NEGATIVE_INFINITY; // False Statements System.out.println( nan == nan ); System.out.println( nan < nan ); System.out.println( nan > nan ); System.out.println( positiveInfinity < positiveInfinity ); // True Statements System.out.println( positiveInfinity == positiveInfinity ); System.out.println( 5.2 < positiveInfinity ); System.out.println( 5.2 > negativeInfinity ); } }