Consider the following interface definition:
interface Printable{ int type = 0; public void jump (); }
Now consider the following class:
public class main implements Printable{ public main (){ type = 1;// w w w. j av a 2s . c o m } public void jump (){ System.out.println ("jumping..."+type); } public static void main (String [] args){ Printable b = new main (); b .jump (); } }
What will the program print when compiled and run?
Select 1 option
Correct Option is : C
Fields defined in an interface are ALWAYS considered as public, static, and final.
Methods are public and abstract.
Even if you don't explicitly define them as such.
You cannot even declare a field to be private or protected in an interface.
You cannot assign any value to 'type' outside the interface definition.