Problem statement:
Given the code of java. Can you tell me the output of this?
compilation error at line number 17 due to a.getData(). Here getData() is not a method of Annonymous interface.
Given the code of java. Can you tell me the output of this?
- interface Annonymous {
- public int getValue();
- }
- public class Sample1 {
- int data = 15;
- public static void main(String[] args) {
- Annonymous a = new Annonymous() {
- int data = 5;
- public int getValue() {
- return data;
- }
- public int getData() {
- return data;
- }
- };
- Sample1 s = new Sample1();
- System.out.println(a.getValue() + a.getData() + s.data);
- }
- }
compilation error at line number 17 due to a.getData(). Here getData() is not a method of Annonymous interface.
No comments:
Post a Comment