in Education by
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

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.

Related questions

0 votes
    What will be the output of the following Java program? public class Test { public static void main( ... stackoverflow.com 🔗Source: Java Interview Questions and Answers...
asked Dec 19, 2020 in Technology by Editorial Staff
0 votes
    What is the output of the following Java program? class Test { int i; } public class Main { public static void main (String ... test = new Test(); System.out.println(test.i); } }...
asked Nov 19, 2020 in Education by Editorial Staff
0 votes
    What is the output of the following Java program? public class Test { Test(int a, int b) { System.out.println("a = "+a+" b = "+ ... 10; byte b = 15; Test test = new Test(a,b); } }...
asked Nov 19, 2020 in Education by Editorial Staff
0 votes
    What is the output of the following Java program? What is the output of the following Java program? class Test { public static ... ) { System.out.println("Hello Javatpoint"); } } }...
asked Nov 17, 2020 in Education by Editorial Staff
0 votes
    What is the output of the following Java program? class Test { public static void main (String args[]) { System.out.println(10 ... * 20); } } The output of the above code will be...
asked Nov 17, 2020 in Education by Editorial Staff
0 votes
    What is the output of the following Java program? class Test { public static void main (String args[]) { System.out.println(10 ... ; System.out.println("Javatpoint" + 10 + 20); } }...
asked Nov 17, 2020 in Education by Editorial Staff
0 votes
    What will be the output of the following Python program? z=set('abc') z.add('san') z.update(set(['p', 'q'] ... ;, ‘c’, [‘p’, ‘q’], ‘san}...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python program? def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc ... (id(q) == foo(q)) a) Error b) None c) False d) True...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python program? z=set('abc') z.add('san') z.update(set(['p', 'q'] ... ;, ‘c’, [‘p’, ‘q’], ‘san}...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python program? def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc ... (id(q) == foo(q)) a) Error b) None c) False d) True...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What is the output of the following program? 3 . #include using namespace std; struct Time { int hours; int ... 20000 D. O 15000 Select the correct answer from above options...
asked Dec 27, 2021 in Education by JackTerrance
0 votes
    What is the output of the following program? 3 . #include using namespace std; struct Time { int hours; int ... 20000 D. O 15000 Select the correct answer from above options...
asked Dec 26, 2021 in Education by JackTerrance
0 votes
    What will be the output of the following program? public class MyFirst { public static void main(String[ ... stackoverflow.com 🔗Source: Java Interview Questions and Answers...
asked Dec 19, 2020 in Technology by Editorial Staff
...