Welcome Guest | Sign in | Register
Interface - Discussion Page For Q.2871 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Interface > Questions and Answers

Q: interface A{
Int i=0;
}
interface B extends A{
Int i=1;
}
interface C extends A, B{
Int i=2;
}

Class Manager implements A,B, C
{
Int i=3;
Public static void main(String args[])
{
A a1=new Manager();
System.out.println(((B)(C)(B)a1).i);
}
}
A. 3 B. ClassCastException
C. compiletime error D. 1

Answer and Explanation

Answer:1

Explanation:
Here a class Manager implements A,B, C which is an interface so it will not throw any compile time error,and while creating an object we are creating an object of manager and trying to store in an a1 variable which is of type any type A,B, C.and manager is also of type A,B, C.. So ans is d)

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.