Menu
Question Index
...

At what line will the run-time exception occur?

class MTest
{
    public static void main(String[] args)
    {
        M m = new M();
        N n = new N();
        m = n;          // LINE A
        O o = new O();
        m = o;          // LINE B
        O o2 = (O) m;   // LINE C
        N n2 = (N) m;   // LINE D
    }
}

class M { }
class N extends M { }
class O extends M { }


LINE A
LINE B
LINE C
LINE D
Compilation Error

Doubts

Problems

Topic: Assigning Super Class Reference To A Sub Class Reference In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App