Welcome Guest | Sign in | Register
Interface - Discussion Page For Q.2870 | 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 B{
Int i=2;
}

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

Answer and Explanation

Answer:3

Explanation:
Here a class Manager implements 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 c1 variable which is of type C.and manager is also of type C.. So ans is a)

Comment on this Question

Name:

Loading...




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