SCJA
~Currently preparing for SCJP6
Originally posted by Jayakumar Ramalingam:
I am getting compile time error on both the places
interface I{}
class A{}
class B implements I{}
class C extends A{}
class D{}
final class E{}
class test{
public static void main(String args[])
{
I ob1 = new A(); //Compile time error
I ob2 = new E(); //Compile time error.
I ob3 = new B();
}
}
My Blog SCJP 5 SCWCD 5
Originally posted by Himanshu Gupta:
I will try to point out the logic which i got from the above discussion:
We can cast user defined class to any user defined interface. (Explicit casting necessary. There will be no compiler error but will through ClassCastException if it fails to pass 'IS A' test.) We cannot cast already present(Java API) class to already given Interfaces as their relationship is already defined.
We can cast user defined class to any user defined interface. (Explicit casting necessary. There will be no compiler error but will through ClassCastException if it fails to pass 'IS A' test.)
My Blog SCJP 5 SCWCD 5
Am i right this time? Please help.
My Blog SCJP 5 SCWCD 5
I think this will make my point a bit clear.
Author of ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- OCPJP Online Training -- Twitter -- How to Ask a Question
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|