0 votes
in Education by (54.6k points)
What is the output of the following Java program?

class Test   

{  

    int test_a, test_b;  

    Test(int a, int b)   

    {  

    test_a = a;   

    test_b = b;   

    }  

    public static void main (String args[])   

    {  

        Test test = new Test();   

        System.out.println(test.test_a+" "+test.test_b);  

    }  

}

1 Answer

0 votes
by (54.6k points)

What is the output of the following Java program?

class Test   

{  

    int test_a, test_b;  

    Test(int a, int b)   

    {  

    test_a = a;   

    test_b = b;   

    }  

    public static void main (String args[])   

    {  

        Test test = new Test();   

        System.out.println(test.test_a+" "+test.test_b);  

    }  

}  

There is a compiler error in the program because there is a call to the default constructor in the main method which is not present in the class. However, there is only one parameterized constructor in the class Test. Therefore, no default constructor is invoked by the constructor implicitly.

...