Java
Programming and Technical
Programming
Output
What will be the output of the following program?
class A
{
public void test()
{
System.out.println("Class A");
}
}
class Trial extends A
{
public void test()
{
System.out.println("Class Trial");
}
public static void main(String args[])
{
Trial object = (Trial)new A();
object.test();
}
}
A. Runtime Error
B. Compile Time Error
C. Class A
D. Class Trial
Read Solution (Total 2)
-
- Object of a subclass cannot be cast to a superclass type. This results in a runtime error.
- 1 year agoHelpfull: Yes(0) No(0)
- Class Trial
- 16 Days agoHelpfull: Yes(0) No(0)
Java Other Question