Problem statement: 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() + s.data);
- }
- }
Output:
20
No comments:
Post a Comment