MCQ Practice Single Best Answer Topic: Java Constructor and Methods

Q What is the output of the program?
class Test{ 
        public int display(int x, int y){ 
                return ("The sum of x and y is " + x + y); 
        } 

        public static void main(String args[]){ 
                Test test = new Test();
                System.out.println(test.display(4,5)); 
        } 
}

Question ID
#2178
Subchapter
Java Constructor and Methods
Action
Choose one option below

Choose Your Answer

Click an option to check whether your answer is correct.

  • A The sum of x and y is 9
  • B The sum of x and y is 45
  • C does not compile
  • D None of the above
Correct Answer: C

Explanation

does not compile

Share This Question

Share this MCQ with your friends or study group.