Question 104Asked in BEL PE Computer Science, 20 Dec 2025 (5:00 PM)

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?
  1. A20 20 10 and 10 10
  2. B20 5 50 and 10 10
  3. C20 5 10 and 50 50
  4. D20 5 10 and 10 50
Show answerHide answer

Correct answer: (D) 20 5 10 and 10 50

From BEL PE Computer Science PYQ, 20 Dec 2025 (5:00 PM)

This is question 104 of BEL PE Computer Science PYQ, 20 Dec 2025 (5:00 PM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.