Consider the following Java program: class Demo {
Consider the following Java program:
class Demo {
int x = 5;
static int y = 10;
void display() {
int x = 20;
System.out.println(x + " " + this.x + " " + y);
}
}
class Test {
static int y = 50;
public static void main(String[] args) {
Demo d = new Demo();
d.display();
System.out.println(d.y + " " + y);
}
}
What will be the output of the program?
Show answerHide answer
Correct answer: (D) 20 5 10 and 10 50