Skip to content
Related Articles

Related Articles

Java | Constructors | Question 5
  • Last Updated : 09 Jan, 2014

Output of following Java program

class Point {
  int m_x, m_y;
  public Point(int x, int y) { m_x = x; m_y = y; }
  public Point() { this(10, 10); }
  public int getX() { return m_x; }
  public int getY() { return m_y; }
  public static void main(String args[]) {
    Point p = new Point();

(A) 10
(B) 0
(C) compiler error

Answer: (A)

Explanation: it’s a simple program where constructor is called with parameters and values are initialized.

Quiz of this Question

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :