Skip to content
Related Articles
Open in App
Not now

Related Articles

Java | Constructors | Question 5

Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 28 Jun, 2021
Improve Article
Save Article

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

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!