Given following classes:
 
class A { int x; } 

class B : A { int y; } 
Which code fragments will compile successfully?
Explanation
Object a = new A();
Object b = (B)a;
will compile successfully as well, but will throw an exception at runtime

@ip41m0334 true! thanks

2017 Dec 6, 11:40:45 AM

Object a = new A(); Object b = (B)a; will compile succesfully, but throw an exception at runtime

2017 Sep 29, 9:34:11 PM

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты