Consider the following Java program: class Demo { int x = 5; static int y =…
BEL Probationary Engineer 2025
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?
- A.
20 20 10 and 10 10
- B.
20 5 50 and 10 10
- C.
20 5 10 and 10 50
- D.
20 5 10 and 50 50
Attempted by 18 students.
Sign up free to check your answer
Sign up freeLoading lesson…

