Home What kind of Exception occurred?
Reply: 0

What kind of Exception occurred?

user640
1#
user640 Published in July 15, 2018, 9:20 pm

I tried to create a test ClassCastException:

In line 1: it prints out class cast exception as I expected
In line 2: it just prints exception.RuntimeExceptionTest$1B@7852e922 (RuntimeExceptionTest is my class name). I wonder what kind of exception here?

 try {
            class A { }
            class B extends A {}
            class C extends A {}
            A objA = new B();
            System.out.println((C)objA); // Line 1
            System.out.println((A)objA); // Line 2
        } catch (Exception e) {
            e.printStackTrace();
        }
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30185 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO