/**
* write another prog in which interface K1 declares method named methodK()
* and a variable intK which is intialised to 1.
* interface
* interface K3 extends
* the return type of methodK() is void in all interfaces.
* class U implements K3.its version of methodK() displays the value of intK.
* instantiate U and invoke its method
*
*
*/
/**
* first base interface
*/
interface K1 {
// that would be printed
int intK = 1;
// will be used to display value of intK
void methodK();
}
/**
* extends K1
*
*
*/
interface
// overrides K1 method
void methodK();
}
/**
* extends
*
*
*/
interface K3 extends
// overrides
void methodK();
}
/**
* implements interface K3 and displays value of intK
*
*
*/
class U implements K3 {
/**
* displays value of intK
*/
public void methodK() {
System.out.println("Value of intK : " + intK);
}
}
/**
* a class that will be executed
*
*
*/
public class InterfaceTest {
/**
* execution begn from here
*
* @param args
* commandline arguments
*/
public static void main(String[] args) {
// create instance of U
new U().methodK();
}
}
No comments:
Post a Comment