0 votes
11 views
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);  

    }  

}
in Education by (48.2k points)

1 Answer

0 votes

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.

by (48.2k points)

Related questions

0 votes
1 answer 11 views
0 votes
1 answer 11 views
0 votes
1 answer 12 views
0 votes
1 answer 9 views
0 votes
1 answer 13 views
0 votes
1 answer 43 views
0 votes
1 answer 13 views
0 votes
1 answer 45 views
0 votes
1 answer 12 views
0 votes
1 answer 33 views
0 votes
1 answer 12 views
0 votes
1 answer 1.7k views
+1 vote
1 answer 88 views
...