0 votes
11 views
What is the output of the following Java program?

public class Test   

{  

    Test(int a, int b)  

    {  

        System.out.println("a = "+a+" b = "+b);  

    }  

    Test(int a, float b)  

    {  

        System.out.println("a = "+a+" b = "+b);  

    }  

    public static void main (String args[])  

    {  

        byte a = 10;   

        byte b = 15;  

        Test test = new Test(a,b);  

    }  

}
in Education by (48.2k points)

1 Answer

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 = "+b);  

    }  

    Test(int a, float b)  

    {  

        System.out.println("a = "+a+" b = "+b);  

    }  

    public static void main (String args[])  

    {  

        byte a = 10;   

        byte b = 15;  

        Test test = new Test(a,b);  

    }  

}  

The output of the following program is:

a = 10 b = 15

Here, the data type of the variables a and b, i.e., byte gets promoted to int, and the first parameterized constructor with the two integer parameters is called.

by (48.2k points)

Related questions

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 11 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
...